Class: Hurley::Request

Inherits:
Struct
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hurley/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



135
136
137
# File 'lib/hurley/client.rb', line 135

def body
  @body
end

#headerObject

Returns the value of attribute header

Returns:

  • (Object)

    the current value of header



135
136
137
# File 'lib/hurley/client.rb', line 135

def header
  @header
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



135
136
137
# File 'lib/hurley/client.rb', line 135

def options
  @options
end

#ssl_optionsObject

Returns the value of attribute ssl_options

Returns:

  • (Object)

    the current value of ssl_options



135
136
137
# File 'lib/hurley/client.rb', line 135

def ssl_options
  @ssl_options
end

#urlObject

Returns the value of attribute url

Returns:

  • (Object)

    the current value of url



135
136
137
# File 'lib/hurley/client.rb', line 135

def url
  @url
end

#verbObject

Returns the value of attribute verb

Returns:

  • (Object)

    the current value of verb



135
136
137
# File 'lib/hurley/client.rb', line 135

def verb
  @verb
end

Instance Method Details

#body_ioObject



156
157
158
159
160
161
162
163
164
# File 'lib/hurley/client.rb', line 156

def body_io
  return unless body

  if body.respond_to?(:read)
    body
  elsif body
    StringIO.new(body)
  end
end

#inspectObject



170
171
172
173
174
175
176
# File 'lib/hurley/client.rb', line 170

def inspect
  "#<%s %s %s>" % [
    self.class.name,
    verb.to_s.upcase,
    url.to_s,
  ]
end

#on_body(*statuses) ⇒ Object



166
167
168
# File 'lib/hurley/client.rb', line 166

def on_body(*statuses)
  @body_receiver = [statuses.empty? ? nil : statuses, Proc.new]
end

#prepare!Object



178
179
180
181
182
183
184
185
186
187
188
# File 'lib/hurley/client.rb', line 178

def prepare!
  prepare_basic_auth!

  if body
    prepare_body!
  else
    return unless REQUIRED_BODY_VERBS.include?(verb)
  end

  prepare_content_length!
end

#query_stringObject



152
153
154
# File 'lib/hurley/client.rb', line 152

def query_string
  url.query.to_query_string
end