diff options
-rwxr-xr-x | www.tcl | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -59,16 +59,17 @@ namespace eval www { my variable to_parse chan stage headers arguments uri path body switch $stage { headers { - if {[catch {append to_parse [read $chan]}] != 0} { + if {[catch {append to_parse [gets $chan]}] != 0} { my destroy } + append to_parse "\n" if {[string first "\n\n" $to_parse] != -1} { set raw_headers [split $to_parse "\n"] set i 0 foreach hdr [lreplace $raw_headers 0 0] { - lappend headers [string trim [lindex [split $hdr :] 0]] + lappend hdrs [string trim [lindex [split $hdr :] 0]] set value [lreplace [split $hdr :] 0 0] - lappend headers [string trim [join $value :]] + lappend hdrs [string trim [join $value :]] } set components {} @@ -79,8 +80,8 @@ namespace eval www { } set uri [lindex $components 1] - dict map {key value} $headers { - set key [string tolower $key] + dict for {key value} $hdrs { + dict append headers [string tolower $key] $value } set path [lindex [split $uri "?"] 0] @@ -101,7 +102,7 @@ namespace eval www { if {[catch {append to_parse [read $chan]}] != 0} { my destroy } - if {[string length to_parse] == [dict get $headers content-length]} { + if {[string length $to_parse] == [dict get $headers content-length]} { lappend arguments {*}[split $to_parse "%=;"] set body $to_parse set stage read @@ -163,7 +164,7 @@ Connection: close </form> " } - server create s 8251 "/* [namespace which action]" + server create s 0 "/* [namespace which action]" puts "http://127.0.0.1:[s ports]/helloworld" vwait forever } |