class SimpleHttp::SimpleHttpResponse
Constants
- SEP
Public Class Methods
new(response_text)
click to toggle source
# File enzi-lib.rb, line 838 def initialize(response_text) @response = {} if response_text.empty? @response["header"] = nil elsif response_text.include?(SEP + SEP) @response["header"], @response["body"] = response_text.split(SEP + SEP) else @response["header"] = response_text end parse_header self end
Public Instance Methods
[](key)
click to toggle source
# File enzi-lib.rb, line 851 def [](key); @response[key]; end
[]=(key, value)
click to toggle source
# File enzi-lib.rb, line 852 def []=(key, value); @response[key] = value; end
body()
click to toggle source
# File enzi-lib.rb, line 855 def body; @response['body']; end
code()
click to toggle source
# File enzi-lib.rb, line 857 def code; @response['code']; end
content_length()
click to toggle source
# File enzi-lib.rb, line 860 def content_length; @response['content-length']; end
content_type()
click to toggle source
# File enzi-lib.rb, line 859 def content_type; @response['content-type']; end
date()
click to toggle source
# File enzi-lib.rb, line 858 def date; @response['date']; end
each(&block)
click to toggle source
# File enzi-lib.rb, line 862 def each(&block) if block @response.each do |k,v| block.call(k,v) end end end
each_name(&block)
click to toggle source
# File enzi-lib.rb, line 867 def each_name(&block) if block @response.each do |k,v| block.call(k) end end end
header()
click to toggle source
# File enzi-lib.rb, line 854 def header; @response['header']; end
parse_header()
click to toggle source
private
# File enzi-lib.rb, line 874 def parse_header return unless @response["header"] h = @response["header"].split(SEP) if h[0].include?("HTTP/1") @response["status"] = h[0].split(" ", 2).last @response["code"] = h[0].split(" ", 3)[1].to_i end h.each do |line| if line.include?(": ") k,v = line.split(": ") @response[k.downcase] = v end end end
status()
click to toggle source
# File enzi-lib.rb, line 856 def status; @response['status']; end