lib/rex/proto/http/packet.rb in librex-0.0.4 vs lib/rex/proto/http/packet.rb in librex-0.0.5
- old
+ new
@@ -90,11 +90,11 @@
else
parse_body
end
end
rescue
- # This rescue might be a problem because it will swallow TimeoutError
+ # XXX: BUG: This rescue might be a problem because it will swallow TimeoutError
self.error = $!
return ParseCode::Error
end
# Return completed or partial to the parsing status to the caller
@@ -282,28 +282,29 @@
self.transfer_chunked = true
self.auto_cl = false
end
# Determine how to handle data when there is no length header
- if(self.body_bytes_left == -1 and self.transfer_chunked != true)
- if(self.headers['Connection'].to_s.downcase.include?('keep-alive'))
- # If we are using keep-alive, but have no content-length and
- # no chunked transfer header, pretend this is the entire
- # buffer and call it done
- self.body_bytes_left = self.bufq.length
- elsif(not self.transfer_chunked and not self.headers['Content-Length'])
- # RFC 2616 says: "The presence of a message-body in a request
- # is signaled by the inclusion of a Content-Length or
- # Transfer-Encoding header field in the request's
- # message-headers."
- #
- # So if we haven't seen either a Content-Length or a
- # Transfer-Encoding header, there shouldn't be a message body.
- self.body_bytes_left = 0
- else
+ if (self.body_bytes_left == -1)
+ if (not self.transfer_chunked)
+ if (self.headers['Connection'].to_s.downcase.include?('keep-alive'))
+ # If we are using keep-alive, but have no content-length and
+ # no chunked transfer header, pretend this is the entire
+ # buffer and call it done
+ self.body_bytes_left = self.bufq.length
+ elsif (not self.headers['Content-Length'] and self.class == Rex::Proto::Http::Request)
+ # RFC 2616 says: "The presence of a message-body in a request
+ # is signaled by the inclusion of a Content-Length or
+ # Transfer-Encoding header field in the request's
+ # message-headers."
+ #
+ # So if we haven't seen either a Content-Length or a
+ # Transfer-Encoding header, there shouldn't be a message body.
+ self.body_bytes_left = 0
+ #else
# Otherwise we need to keep reading until EOF
- self.body_bytes_left = -1
+ end
end
end
# Throw an error if we didnt parse the header properly
if !self.headers.cmd_string
@@ -388,10 +389,10 @@
return
end
# If there are no more bytes left, then parsing has completed and we're
# ready to go.
- if (self.transfer_chunked != 1 and self.body_bytes_left <= 0)
+ if (not self.transfer_chunked and self.body_bytes_left == 0)
self.state = ParseState::Completed
return
end
end