File tree Expand file tree Collapse file tree 2 files changed +19
-34
lines changed Expand file tree Collapse file tree 2 files changed +19
-34
lines changed Original file line number Diff line number Diff line change 9
9
10
10
require 'async'
11
11
require 'protocol/http/body/file'
12
- require 'async/http/body/delayed'
13
12
require 'async/http/client'
14
13
require 'async/http/endpoint'
15
14
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
+
16
33
Async do
17
34
endpoint = Async ::HTTP ::Endpoint . parse ( "http://localhost:9222" )
18
35
client = Async ::HTTP ::Client . new ( endpoint , protocol : Async ::HTTP ::Protocol ::HTTP2 )
21
38
[ 'accept' , 'text/plain' ] ,
22
39
]
23
40
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 ) )
25
42
26
43
response = client . post ( endpoint . path , headers , body )
27
44
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments