From: SourceForge.net <no...@so...> - 2009-10-09 20:56:28
|
Bugs item #2874782, was opened at 2009-10-08 10:04 Message generated for change (Comment added) made by cwjolly You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=2874782&group_id=10894 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: 29. http Package Group: current: 8.6b1 Status: Open Resolution: None Priority: 5 Private: No Submitted By: C Jolly (cwjolly) Assigned to: Pat Thoyts (patthoyts) Summary: http 2.7.2 fails to correctly parse input Initial Comment: 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" } } } ---------------------------------------------------------------------- >Comment By: C Jolly (cwjolly) Date: 2009-10-09 15:56 Message: The server is on a Tivo Series 2 and so there are millions of instances of this. I should add that the TclCurl extension was used to access this server also and did not suffer this problem. The maxim here is to "send strictly, receive forgivingly.". If it allows the http package to access more web servers and has no ill effects then why not make the change. ---------------------------------------------------------------------- Comment By: Donal K. Fellows (dkf) Date: 2009-10-09 08:41 Message: But that's just a plain-old broken server. At a guess the response should be interpreted as being a very old version of HTTP (I believe there's one that doesn't respond with headers) and if that's a problem, it's the server that ought to be taken out in the back yard and shot. It's for the best. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=2874782&group_id=10894 |