class RaptorIO::Protocol::HTTP::Message
HTTP
message, holds shared attributes of {Request} and {Response}.
@author Tasos Laskos <tasos_laskos@rapid7.com>
Attributes
body[RW]
@return [String] {Request}/{Response} body.
headers[R]
@return [Headers<String, String>] HTTP
headers as a Hash-like object.
version[R]
@return [String] HTTP
version.
Public Class Methods
new( options = {} )
click to toggle source
@note All options will be sent through the class setters whenever
possible to allow for normalization.
@param [Hash] options Message
options. @option options [String] :url The URL of the remote resource. @option options [Hash] :headers HTTP
headers. @option options [String] :body Body. @option options [String] :version (1.1) HTTP
version.
# File lib/raptor-io/protocol/http/message.rb, line 30 def initialize( options = {} ) options.each do |k, v| begin send( "#{k}=", v ) rescue NoMethodError instance_variable_set( "@#{k}".to_sym, v ) end end @headers = Headers.new( @headers ) @version ||= '1.1' end
Public Instance Methods
http_1_0?()
click to toggle source
@return [Boolean]
`true` when {#version} is `1.0`, `false` otherwise.
# File lib/raptor-io/protocol/http/message.rb, line 60 def http_1_0? version == '1.0' end
http_1_1?()
click to toggle source
@return [Boolean]
`true` when {#version} is `1.1`, `false` otherwise.
# File lib/raptor-io/protocol/http/message.rb, line 54 def http_1_1? version == '1.1' end
keep_alive?()
click to toggle source
@return [Bool]
`true` if the connections should be reused, `false` otherwise.
# File lib/raptor-io/protocol/http/message.rb, line 45 def keep_alive? connection = headers['Connection'].to_s.downcase return connection == 'keep-alive' if version.to_f < 1.1 connection != 'close' end