153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
# File 'lib/webmachine/adapters/ring.rb', line 153
def self.from_webmachine(response)
= response.
.delete("Content-Length")
.each do |k, v|
[k] = v.join(", ") if v.is_a? Array
end
response_body = if response.body.respond_to?(:call)
Webmachine::ChunkedBody.new([response.body.call])
elsif response.body.respond_to?(:each)
if response.["Transfer-Encoding"] == "chunked"
Webmachine::ChunkedBody.new(response.body)
else
response.body
end
elsif response.body.is_a? IO
response.body.to_outputstream
else
response.body
end
if response_body.respond_to?(:each)
ring_body = ""
response_body.each do |chunk|
ring_body << chunk.to_s
end
else
ring_body = response_body
end
= Java::JavaUtil::HashMap.new()
ring_response = [
Ring::STATUS , response.code,
Ring::HEADERS , ,
Ring::BODY , ring_body
]
return PersistentHashMap.create(ring_response.to_java)
end
|