File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 8
8
require "async/http/a_protocol"
9
9
10
10
describe Async ::HTTP ::Protocol ::HTTP do
11
+ with "#protocol_for" do
12
+ let ( :protocol ) { subject ::DEFAULT }
13
+ let ( :buffer ) { StringIO . new }
14
+
15
+ it "it can detect http/1.1" do
16
+ buffer . write ( "GET / HTTP/1.1\r \n Host: localhost\r \n \r \n " )
17
+ buffer . rewind
18
+
19
+ stream = IO ::Stream ( buffer )
20
+
21
+ expect ( protocol . protocol_for ( stream ) ) . to be == Async ::HTTP ::Protocol ::HTTP1
22
+ end
23
+
24
+ it "it can detect http/2" do
25
+ # This special preface is used to indicate that the client would like to use HTTP/2.
26
+ # https://www.rfc-editor.org/rfc/rfc7540.html#section-3.5
27
+ buffer . write ( "PRI * HTTP/2.0\r \n \r \n SM\r \n \r \n " )
28
+ buffer . rewind
29
+
30
+ stream = IO ::Stream ( buffer )
31
+
32
+ expect ( protocol . protocol_for ( stream ) ) . to be == Async ::HTTP ::Protocol ::HTTP2
33
+ end
34
+ end
35
+
11
36
with "server" do
12
37
include Sus ::Fixtures ::Async ::HTTP ::ServerContext
13
38
let ( :protocol ) { subject }
You can’t perform that action at this time.
0 commit comments