diff options
| author | Jacob Haip <jhaip@users.noreply.github.com> | 2023-03-23 03:10:20 +0000 |
|---|---|---|
| committer | Jacob Haip <jhaip@users.noreply.github.com> | 2023-03-23 03:10:20 +0000 |
| commit | ab2659b28592bfdb4d03365ddcd39bf5c6f7ae2f (patch) | |
| tree | 24e704ce507630f8eb1b1ffe2016b6b9ab3975a8 | |
| parent | move new-program-web-editor to virtual-programs (diff) | |
| download | folk-ab2659b28592bfdb4d03365ddcd39bf5c6f7ae2f.tar.gz folk-ab2659b28592bfdb4d03365ddcd39bf5c6f7ae2f.zip | |
fix handling of web response with contentType and body
| -rw-r--r-- | web.tcl | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -96,24 +96,24 @@ proc handleRead {chan addr port} { if {$response ne "" && [dict exists $response raw]} { puts -nonewline $chan [dict get $response raw] } else { - set response {} + set finalResponse {} if {$html ne ""} { - set response $html + set finalResponse $html } elseif {$response ne ""} { if {[dict exists $response contentType]} { set contentType [dict get $response contentType] } if {[dict exists $response body]} { - set response [dict get $response body] + set finalResponse [dict get $response body] } else { - set response "error missing body" + set finalResponse "error missing body" } } else { - set response [handlePage $path contentType] + set finalResponse [handlePage $path contentType] } puts -nonewline $chan "HTTP/1.1 200 OK\nConnection: close\nContent-Type: $contentType\n\n" chan configure $chan -encoding binary -translation binary - puts -nonewline $chan $response + puts -nonewline $chan $finalResponse } close $chan } elseif {[::websocket::test $::serverSock $chan "/ws" $headers]} { |
