File tree 2 files changed +52
-1
lines changed
lib/async/http/protocol/http1
2 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ class Finishable < ::Protocol::HTTP::Body::Wrapper
15
15
def initialize ( body )
16
16
super ( body )
17
17
18
+ $stderr. puts "Finishable#initialize: #{ body . inspect } "
19
+
18
20
@closed = Async ::Variable . new
19
21
@error = nil
20
22
@@ -28,12 +30,16 @@ def reading?
28
30
def read
29
31
@reading = true
30
32
31
- super
33
+ super . tap do |chunk |
34
+ $stderr. puts "Finishable#read: #{ chunk . inspect } "
35
+ end
32
36
end
33
37
34
38
def close ( error = nil )
35
39
super
36
40
41
+ $stderr. puts "Finishable#close: #{ error . inspect } "
42
+
37
43
unless @closed . resolved?
38
44
@error = error
39
45
@closed . value = true
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2018-2024, by Samuel Williams.
5
+
6
+ require "sus/fixtures/async/http"
7
+
8
+ APostRequest = Sus ::Shared ( "a post request" ) do
9
+ include Sus ::Fixtures ::Async ::HTTP ::ServerContext
10
+ let ( :protocol ) { subject }
11
+
12
+ let ( :app ) do
13
+ ::Protocol ::HTTP ::Middleware . for do |request |
14
+ ::Protocol ::HTTP ::Response [ 200 , { } , request . body ]
15
+ end
16
+ end
17
+
18
+ it "can post a fixed length body" do
19
+ $stderr. puts "Connecting to server: #{ subject } "
20
+ body = Protocol ::HTTP ::Body ::Buffered . wrap ( [ "Hello, World!" ] )
21
+
22
+ begin
23
+ response = client . post ( "/" , body : body )
24
+
25
+ $stderr. puts "Got response: #{ response . inspect } "
26
+
27
+ expect ( response ) . to be ( :success? )
28
+ expect ( response . read ) . to be == "Hello, World!"
29
+ ensure
30
+ response &.finish
31
+ end
32
+ end
33
+ end
34
+
35
+ describe Async ::HTTP ::Protocol ::HTTP10 do
36
+ it_behaves_like APostRequest
37
+ end
38
+
39
+ describe Async ::HTTP ::Protocol ::HTTP11 do
40
+ it_behaves_like APostRequest
41
+ end
42
+
43
+ describe Async ::HTTP ::Protocol ::HTTP2 do
44
+ it_behaves_like APostRequest
45
+ end
You can’t perform that action at this time.
0 commit comments