Overview
| Artifact ID: | 147effcd63903d7bb114de9a2770d21465eb5ec2583635d0a041c6378fe019b9 |
|---|---|
| Ticket: | 2874782fffffffffffffffffffffffffffffffff
http 2.7.2 fails to correctly parse input |
| User & Date: | kjnash on 2022-05-30 21:31:33 |
Changes
- closer changed to: "nobody"
- comment changed to:
The http event handler function does not handle web servers that put in blank lines ahead of the http response header. This is not to standard but I believe the fix I am suggesting does not harm other web servers that do return the status on the first line. I am connecting to a webserver that sends back the following to a GET request : --------------------------- \n \n \n HTTP/1.1 200 File Follows \n ..... ------- without the suggested change the current 2.7.2 version of http.tm files to parse the reply. The status is blank and the metadata holds the contents of the body. This totally screws up the retrieval of elements using the http api. The following change will not set the header until it gets a non blank line. The relevant portions are shown; all other code has been removed for the sake of brevity. The http::Event proc needs to be modified from : # current version 2.7.2 proc http::Event { socket token } { .... if {$state(state) eq "connecting"} { set state(state) "header" if {[catch {gets $sock state(http)} n]} { return [Finish $token $n] } } ... } to : # suggested update proc http::Event { soket token } { .... if {$state(state) eq "connecting"} { if {[catch {gets $sock state(http)} n]} { return [Finish $token $n] } else { if { [string length $state(http) ] > 0 } { set state(state) "header" } } } - icomment:
I am not inclined to revise http for this case. It is awkward enough to write a HTTP client for standards-compliant servers (e.g. to get chunked encoding, unchunked encoding, and Keep-Alive right) without also attempting to work with non-compliant servers. I have set the "Resolution" field to "Invalid" because this is not a bug in Tcl.
- login: "kjnash"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- severity changed to: "Minor"
- status changed to: "Pending"
- title changed to: "http 2.7.2 fails to correctly parse input"