Permalink
Browse files

Merge pull request #46 from SebastianEdwards/reel

Fix Reel Adapter
  • Loading branch information...
2 parents a2ae664 + f5a08cd commit e0b21df21974b7c432ad4acdfdc6eb030c2776fe @seancribbs seancribbs committed May 17, 2012
Showing with 20 additions and 20 deletions.
  1. +20 −20 lib/webmachine/adapters/reel.rb
@@ -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

0 comments on commit e0b21df

Please sign in to comment.