Class: RoadForest::HTTP::Request

Inherits:
Message
  • Object
show all
Defined in:
lib/roadforest/http/message.rb

Instance Attribute Summary collapse

Attributes inherited from Message

#headers

Instance Method Summary collapse

Methods inherited from Message

#body, #body=, #body_string, #body_string=, #empty?, #inspection_stream

Constructor Details

#initialize(method, url) ⇒ Request

Returns a new instance of Request.



77
78
79
80
81
# File 'lib/roadforest/http/message.rb', line 77

def initialize(method, url)
  super()
  @method, @url = method, url
  headers["Host"] = Addressable::URI.parse(url).host
end

Instance Attribute Details

#methodObject

Returns the value of attribute method.



75
76
77
# File 'lib/roadforest/http/message.rb', line 75

def method
  @method
end

#urlObject

Returns the value of attribute url.



75
76
77
# File 'lib/roadforest/http/message.rb', line 75

def url
  @url
end

Instance Method Details

#inspectObject



83
84
85
# File 'lib/roadforest/http/message.rb', line 83

def inspect
  "\n" + super
end

#inspection_payloadObject



91
92
93
# File 'lib/roadforest/http/message.rb', line 91

def inspection_payload
  [url, "#{method} #{url.path}"] + super
end

#needs_body?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/roadforest/http/message.rb', line 87

def needs_body?
  %w{POST PATCH PUT}.include?(@method)
end