Skip to content

Commit 4aa2076

Browse files
committed
Update handling of trailers.
1 parent d2cc50f commit 4aa2076

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

async-http.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
2121
spec.add_dependency("async-io", "~> 1.28")
2222
spec.add_dependency("async-pool", "~> 0.2")
2323

24-
spec.add_dependency("protocol-http", "~> 0.16.0")
24+
spec.add_dependency("protocol-http", "~> 0.17.0")
2525
spec.add_dependency("protocol-http1", "~> 0.11.0")
2626
spec.add_dependency("protocol-http2", "~> 0.13.0")
2727

lib/async/http/protocol/http1/client.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def call(request, task: Task.current)
3939
raise RequestFailed
4040
end
4141

42+
request.headers.trailers!
43+
4244
if request.body?
4345
body = request.body
4446

lib/async/http/protocol/http1/server.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def each(task: Task.current)
6161

6262
if response
6363
write_response(@version, response.status, response.headers)
64+
response.headers.trailers!
6465

6566
body = response.body
6667

spec/async/http/protocol/shared_examples.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,14 @@
9797
Protocol::HTTP::Response[200, [], "request trailers"]
9898
else
9999
headers = Protocol::HTTP::Headers.new
100-
headers.add('etag') {'abcd'}
100+
headers.add('trailers', 'etag')
101101

102102
body = Async::HTTP::Body::Writable.new
103103

104104
Async do |task|
105105
body.write("response trailers")
106106
task.sleep(0.01)
107+
headers.add('etag', 'abcd')
107108
body.close
108109
end
109110

@@ -114,12 +115,13 @@
114115

115116
it "can send request trailers" do
116117
headers = Protocol::HTTP::Headers.new
117-
headers.add('etag') {'abcd'}
118+
headers.add('trailers', 'etag')
118119
body = Async::HTTP::Body::Writable.new
119120

120121
Async do |task|
121122
body.write("Hello")
122123
task.sleep(0.01)
124+
headers.add('etag', 'abcd')
123125
body.close
124126
end
125127

0 commit comments

Comments
 (0)