File tree 2 files changed +18
-42
lines changed
2 files changed +18
-42
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 6
6
require 'async/http/client'
7
7
require 'async/http/endpoint'
8
8
9
+ require 'protocol/http/accept_encoding'
10
+
9
11
require 'sus/fixtures/async'
10
12
11
13
describe Async ::HTTP ::Client do
14
16
let ( :endpoint ) { Async ::HTTP ::Endpoint . parse ( 'https://www.google.com' ) }
15
17
let ( :client ) { Async ::HTTP ::Client . new ( endpoint ) }
16
18
19
+ it "should specify a hostname" do
20
+ expect ( endpoint . hostname ) . to be == "www.google.com"
21
+ expect ( client . authority ) . to be == "www.google.com"
22
+ end
23
+
17
24
it 'can fetch remote resource' do
18
25
response = client . get ( '/' , 'accept' => '*/*' )
19
26
23
30
24
31
client . close
25
32
end
33
+
34
+ it "can request remote resource with compression" do
35
+ compressor = Protocol ::HTTP ::AcceptEncoding . new ( client )
36
+
37
+ response = compressor . get ( "/" , { 'accept-encoding' => 'gzip' } )
38
+
39
+ expect ( response ) . to be ( :success? )
40
+
41
+ expect ( response . body ) . to be_a Async ::HTTP ::Body ::Inflate
42
+ expect ( response . read ) . to be ( :start_with? , '<!doctype html>' )
43
+ end
26
44
end
You can’t perform that action at this time.
0 commit comments