Skip to content

Commit 8523d4f

Browse files
committed
Simpler annotations.
1 parent 67aa1dd commit 8523d4f

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

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

+3-9
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,16 @@ def call(request, task: Task.current)
3333

3434
if protocol = request.protocol
3535
# 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.
36-
task.async do |subtask|
37-
subtask.annotate("Upgrading request.")
38-
36+
task.async(annotation: "Upgrading request...") do
3937
# If this fails, this connection will be closed.
4038
write_upgrade_body(protocol, body)
4139
end
4240
elsif request.connect?
43-
task.async do |subtask|
44-
subtask.annotate("Tunnelling body.")
45-
41+
task.async(annotation: "Tunnneling request...") do
4642
write_tunnel_body(@version, body)
4743
end
4844
else
49-
task.async do |subtask|
50-
subtask.annotate("Streaming body.")
51-
45+
task.async(annotation: "Streaming request...") do
5246
# 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.
5347
write_body(@version, body, false, trailer)
5448
end

0 commit comments

Comments
 (0)