possible fix for header parsing issue

git-svn-id: file:///home/svn/incoming/trunk@3390 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Miller 2006-01-16 16:29:22 +00:00
parent ef8e171e2a
commit 0b27b07a5d
2 changed files with 5 additions and 11 deletions

View File

@ -80,8 +80,6 @@ class Packet
rescue
self.error = $!
puts "#{self.error}: \n#{$@.join("\n")}"
return ParseCode::Error
end
@ -235,15 +233,9 @@ protected
# transition to the body parsing phase.
idx = self.bufq.index(/\r*\n\r*\n/)
if (idx == -1)
self.headers.from_s(self.bufq)
else
idx += 4
end
if (idx >= 0)
if (idx and idx >= 0)
# Extract the header block
head = self.bufq.slice!(0, idx)
head = self.bufq.slice!(0, idx + 4)
# Serialize the headers
self.headers.from_s(head)
@ -273,6 +265,8 @@ protected
else
self.state = ParseState::Completed
end
else
return ParseState::ProcessingHeader
end
# No command string? Wack.

View File

@ -15,6 +15,7 @@ class Rex::Proto::Http::Packet::UnitTest < Test::Unit::TestCase
req1 =
"GET / HTTP/1.0\r\n" +
"Foo: Bird\r\n" +
"Connection: close\r\n" +
"Accept: text/html\r\n" +
"\r\n" +
"Super body"
@ -26,7 +27,6 @@ class Rex::Proto::Http::Packet::UnitTest < Test::Unit::TestCase
assert_equal("Bird", h.headers['Foo'])
assert_equal("text/html", h.headers['Accept'])
assert_equal("Super body", h.body);
assert_equal(req1, h.to_s)
end
def test_to_s