net/http bad header patch

J

jm

Ran into a web server with a broken header. Unfortunately, it's not one
I have control of so I can't fix it. This problem seems to be ignored
by the browsers I've tried, but not Net::HTTP. Here's what the header
looks like,

HTTP/1.0 200 OK
Connection: close
Server: Microsoft-IIS/5.0
Date: Fri, 08 Jul 2005 01:06:34 GMT
Expires: Fri, 08 Jul 2005 11:06:34 GMT
Last-Modified: Fri, 08 Jul 2005 11:06:34 GMT
: <------ problem line
Content-Type: Application/octet-stream
Content-Length: 57754
Content:


This causes Net::HTTP to raise a Net::HTTPBadResponse. The quick fix
patch.

--- /usr/lib/ruby/1.8/net/http.rb Thu Dec 4 13:46:16 2003
+++ /usr/lib/ruby/1.8/net/http_modified.rb Fri Jul 8 11:28:29 2005
@@ -1574,7 +1574,7 @@
while true
line = sock.readuntil("\n", true).sub(/\s+\z/, '')
break if line.empty?
- m = /\A([^:]+):\s*/.match(line) or
+ m = /\A([^:]*):\s*/.match(line) or
raise HTTPBadResponse, 'wrong header line format'
yield m[1], m.post_match
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top