Skip to content

Commit d634363

Browse files
committed
Remove Async::HTTP::Body::Delayed with no replacement.
1 parent b1c6cf6 commit d634363

File tree

2 files changed

+19
-34
lines changed

2 files changed

+19
-34
lines changed

examples/upload/client.rb

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,27 @@
99

1010
require 'async'
1111
require 'protocol/http/body/file'
12-
require 'async/http/body/delayed'
1312
require 'async/http/client'
1413
require 'async/http/endpoint'
1514

15+
class Delayed < ::Protocol::HTTP::Body::Wrapper
16+
def initialize(body, delay = 0.01)
17+
super(body)
18+
19+
@delay = delay
20+
end
21+
22+
def ready?
23+
false
24+
end
25+
26+
def read
27+
sleep(@delay)
28+
29+
return super
30+
end
31+
end
32+
1633
Async do
1734
endpoint = Async::HTTP::Endpoint.parse("http://localhost:9222")
1835
client = Async::HTTP::Client.new(endpoint, protocol: Async::HTTP::Protocol::HTTP2)
@@ -21,7 +38,7 @@
2138
['accept', 'text/plain'],
2239
]
2340

24-
body = Async::HTTP::Body::Delayed.new(Protocol::HTTP::Body::File.open(File.join(__dir__, "data.txt"), block_size: 32))
41+
body = Delayed.new(Protocol::HTTP::Body::File.open(File.join(__dir__, "data.txt"), block_size: 32))
2542

2643
response = client.post(endpoint.path, headers, body)
2744

lib/async/http/body/delayed.rb

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)