Skip to content

Commit

Permalink
Merge pull request #46 from SebastianEdwards/reel
Browse files Browse the repository at this point in the history
Fix Reel Adapter
  • Loading branch information
seancribbs committed May 17, 2012
2 parents a2ae664 + f5a08cd commit e0b21df
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lib/webmachine/adapters/reel.rb
Expand Up @@ -20,28 +20,28 @@ def run
end

def process(connection)
wreq = connection.request
header = Webmachine::Headers[wreq.headers.dup]
requri = URI::HTTP.build(:host => header.host.split(':').first,
:port => header.host.split(':').last,
if wreq = connection.request
header = Webmachine::Headers[wreq.headers.dup]
requri = URI::HTTP.build(:host => header.fetch('Host').split(':').first,
:port => header.fetch('Host').split(':').last.to_i,
:path => wreq.url.split('?').first,
:query => wreq.url.split('?').last)
request = Webmachine::Request.new(wreq.method.to_s.upcase,
requri,
header,
LazyRequestBody.new(wreq))
response = Webmachine::Response.new
@dispatcher.dispatch(request,response)
# TODO: Chunked encoding support? This completely misses the
# opportunity to stream efficiently.
body = case response.body
when String
body
when Enumerable
body.to_a.join
end
wres = ::Reel::Response.new(response.code, response.headers, body)
connection.respond(wres)
request = Webmachine::Request.new(wreq.method.to_s.upcase,
requri,
header,
LazyRequestBody.new(wreq))
response = Webmachine::Response.new
@dispatcher.dispatch(request,response)

wres = case response.body
when String
::Reel::Response.new(response.code, response.headers, response.body)
when Enumerable
::Reel::StreamingResponse.new(response.code, response.headers, response.body)
end

connection.respond(wres)
end
end
end
end
Expand Down

0 comments on commit e0b21df

Please sign in to comment.