File tree Expand file tree Collapse file tree 2 files changed +52
-1
lines changed
lib/async/http/protocol/http1 Expand file tree Collapse file tree 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
1515 def initialize ( body )
1616 super ( body )
1717
18+ $stderr. puts "Finishable#initialize: #{ body . inspect } "
19+
1820 @closed = Async ::Variable . new
1921 @error = nil
2022
@@ -28,12 +30,16 @@ def reading?
2830 def read
2931 @reading = true
3032
31- super
33+ super . tap do |chunk |
34+ $stderr. puts "Finishable#read: #{ chunk . inspect } "
35+ end
3236 end
3337
3438 def close ( error = nil )
3539 super
3640
41+ $stderr. puts "Finishable#close: #{ error . inspect } "
42+
3743 unless @closed . resolved?
3844 @error = error
3945 @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