Keep response status

master
Jacob Robles 2019-04-23 06:27:12 -05:00
parent d4728c9bc7
commit 80a68de17d
No known key found for this signature in database
GPG Key ID: 3EC9F18F2B12401C
1 changed files with 11 additions and 1 deletions

View File

@ -19,6 +19,9 @@ class Response
attr_accessor :headers
attr_accessor :body
attr_accessor :protocol
attr_accessor :status_code
attr_accessor :message
attr_accessor :bufq
attr_accessor :state
@ -26,6 +29,9 @@ class Response
self.state = ParseState::ProcessingHeader
self.headers = {}
self.body = ''
self.protocol = nil
self.status_code = nil
self.message = nil
self.bufq = ''
parse(buf) if buf
end
@ -84,7 +90,11 @@ class Response
def get_headers(head)
head.each_line.with_index do |l, i|
next if i == 0
if i == 0
self.protocol,self.status_code,self.message = l.split(' ', 3)
self.status_code = self.status_code.to_i if self.status_code
next
end
k,v = l.split(':', 2)
self.headers[k] = v.strip
end