lib/rex/proto/http/packet.rb in librex-0.0.6 vs lib/rex/proto/http/packet.rb in librex-0.0.7
- old
+ new
@@ -164,13 +164,12 @@
#
# Converts the packet to a string.
#
def to_s
- # Duplicate and make sure this is 8BIT safe for Ruby 1.9
- content = self.body.unpack("C*").pack("C*")
-
+ content = self.body.dup
+
# Update the content length field in the header with the body length.
if (content)
if !self.compress.nil?
case self.compress
when 'gzip'
@@ -265,11 +264,11 @@
##
def parse_header
head,data = self.bufq.split(/\r?\n\r?\n/, 2)
-
+
return if not data
self.headers.from_s(head)
self.bufq = data || ""
@@ -337,21 +336,21 @@
# Remove any leading newlines or spaces
self.bufq.lstrip!
# If we didn't get a newline, then this might not be the full
# length, go back and get more.
- # e.g.
+ # e.g.
# first packet: "200"
# second packet: "0\r\n\r\n<html>..."
if not bufq.index("\n")
return
end
# Extract the actual hexadecimal length value
clen = self.bufq.slice!(/^[a-fA-F0-9]+\r?\n/)
clen.rstrip! if (clen)
-
+
# if we happen to fall upon the end of the buffer for the next chunk len and have no data left, go get some more...
if clen.nil? and self.bufq.length == 0
return
end