Class: RoadForest::TestSupport::HTTPClient::Exchange::RequestBody

Inherits:
Object
  • Object
show all
Defined in:
lib/roadforest/test-support/http-client.rb

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ RequestBody

Returns a new instance of RequestBody.

Parameters:

  • request

    the request from Mongrel



122
123
124
# File 'lib/roadforest/test-support/http-client.rb', line 122

def initialize(body)
  @raw_body = body
end

Instance Method Details

#bodyObject



126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/roadforest/test-support/http-client.rb', line 126

def body
  @body =
    case @raw_body
    when IO, StringIO
      @raw_body.rewind
      @raw_body.read
    when String
      @raw_body
    else
      raise "Can't handle body type: #{@raw_body.class}"
    end

end

#each {|chunk| ... } ⇒ Object

Yields:

  • (chunk)

Yield Parameters:

  • chunk (String)

    a chunk of the request body



147
148
149
# File 'lib/roadforest/test-support/http-client.rb', line 147

def each(&block)
  yield(body)
end

#to_sString

Returns the request body as a string.

Returns:

  • (String)

    the request body as a string



141
142
143
# File 'lib/roadforest/test-support/http-client.rb', line 141

def to_s
  body
end