diff --git a/lib/async/http/protocol/http1/client.rb b/lib/async/http/protocol/http1/client.rb index d53122d..2ee4d26 100644 --- a/lib/async/http/protocol/http1/client.rb +++ b/lib/async/http/protocol/http1/client.rb @@ -33,22 +33,16 @@ def call(request, task: Task.current) 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. - task.async do |subtask| - subtask.annotate("Upgrading request.") - + task.async(annotation: "Upgrading request...") do # If this fails, this connection will be closed. write_upgrade_body(protocol, body) end elsif request.connect? - task.async do |subtask| - subtask.annotate("Tunnelling body.") - + task.async(annotation: "Tunnneling request...") do write_tunnel_body(@version, body) end else - task.async do |subtask| - subtask.annotate("Streaming body.") - + task.async(annotation: "Streaming request...") do # 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, false, trailer) end