lib/async/http/protocol/http1/client.rb in async-http-0.50.12 vs lib/async/http/protocol/http1/client.rb in async-http-0.50.13
- old
+ new
@@ -37,10 +37,12 @@
rescue
# If we fail to fully write the request and body, we can retry this request.
raise RequestFailed
end
+ request.headers.trailers!
+
if request.body?
body = request.body
if protocol = request.protocol
# This is a very tricky apect of handling HTTP/1 upgrade connections. In theory, this approach is a bit inefficient, because we spin up a task just to handle writing to the underlying stream when we could be writing to the stream directly. But we need to maintain some level of compatibility with HTTP/2. Additionally, we don't know if the upgrade request will be accepted, so starting to write the body at this point needs to be handled with care.
@@ -59,10 +61,10 @@
else
task.async do |subtask|
subtask.annotate("Streaming body.")
# Once we start writing the body, we can't recover if the request fails. That's because the body might be generated dynamically, streaming, etc.
- write_body(@version, body)
+ write_body(@version, body, false, request.trailers)
end
end
elsif protocol = request.protocol
write_upgrade_body(protocol)
else