Skip to content

Commit

Permalink
Add support for callable bodies.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Apr 19, 2021
1 parent 3ec805b commit 5b73e63
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Documentation

on:
push:
branches:
- master

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
env:
BUNDLE_WITH: maintenance
with:
ruby-version: 2.7
bundler-cache: true

- name: Installing packages
run: sudo apt-get install wget

- name: Generate documentation
timeout-minutes: 5
run: bundle exec bake utopia:project:static

- name: Deploy documentation
uses: JamesIves/github-pages-deploy-action@4.0.0
with:
branch: gh-pages
folder: docs
2 changes: 1 addition & 1 deletion falcon.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |spec|

spec.add_dependency "async", "~> 1.13"
spec.add_dependency "async-container", "~> 0.16.0"
spec.add_dependency "async-http", "~> 0.54.0"
spec.add_dependency "async-http", "~> 0.55.0"
spec.add_dependency "async-http-cache", "~> 0.3.0"
spec.add_dependency "async-io", "~> 1.22"
spec.add_dependency "build-environment", "~> 1.13"
Expand Down
2 changes: 2 additions & 0 deletions gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

gemspec

gem "rack", git: 'https://github.com/ioquatix/rack', branch: 'streaming'

# gem "async-container", path: "../async-container"
# gem "async-websocket", path: "../async-websocket"
# gem "async-http", path: "../async-http"
Expand Down
4 changes: 3 additions & 1 deletion lib/falcon/adapters/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Output < ::Protocol::HTTP::Body::Readable
# @parameter status [Integer] The response status.
# @parameter headers [Protocol::HTTP::Headers] The response headers.
# @parameter body [Object] The `rack` response body.
def self.wrap(status, headers, body)
def self.wrap(status, headers, body, request = nil)
# In no circumstance do we want this header propagating out:
if length = headers.delete(CONTENT_LENGTH)
# We don't really trust the user to provide the right length to the transport.
Expand All @@ -44,6 +44,8 @@ def self.wrap(status, headers, body)

if body.is_a?(::Protocol::HTTP::Body::Readable)
return body
elsif body.respond_to?(:call)
body = Async::HTTP::Body::Hijack.wrap(request, &body)
elsif status == 200 and body.respond_to?(:to_path)
# Don't mangle partial responsese (206)
return ::Protocol::HTTP::Body::File.open(body.to_path)
Expand Down
2 changes: 1 addition & 1 deletion lib/falcon/adapters/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def self.wrap(status, headers, body, request = nil)
Async.logger.warn("Ignoring protocol-level headers: #{ignored.inspect}")
end

body = Output.wrap(status, headers, body)
body = Output.wrap(status, headers, body, request)
end

if request&.head?
Expand Down

0 comments on commit 5b73e63

Please sign in to comment.