File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434 run : rake build
3535 env :
3636 LANG : C
37-
38- test-net-protocol-head :
39- name : test (net-protocol master)
40- runs-on : ubuntu-latest
41- steps :
42- - uses : actions/checkout@v7
43- - name : Set up Ruby
44- uses : ruby/setup-ruby@v1
45- with :
46- ruby-version : ruby
47- - name : Install dependencies
48- run : bundle install
49- env :
50- BUNDLE_WITHOUT : sig
51- NET_PROTOCOL_GIT : " true"
52- - name : Run test
53- run : rake test
54- env :
55- NET_PROTOCOL_GIT : " true"
Original file line number Diff line number Diff line change @@ -6,11 +6,6 @@ gem "rake"
66gem "test-unit"
77gem "test-unit-ruby-core"
88
9- # The response line length limit only takes effect on a net-protocol that
10- # has Net::BufferedIO#readuntil(limit:). Set NET_PROTOCOL_GIT to exercise it
11- # before that release reaches rubygems.org.
12- gem "net-protocol" , git : "https://github.com/ruby/net-protocol" if ENV [ "NET_PROTOCOL_GIT" ]
13-
149group :sig do
1510 gem "rbs"
1611 gem "rdoc"
Original file line number Diff line number Diff line change @@ -155,17 +155,10 @@ def read_new(sock) #:nodoc: internal use only
155155 res
156156 end
157157
158- if defined? ( Net ::ReadLimitExceeded )
159- def read_line ( sock , limit , ignore_eof = false ) #:nodoc: internal use only
160- sock . readuntil ( "\n " , ignore_eof , limit : limit )
161- rescue Net ::ReadLimitExceeded
162- raise Net ::HTTPBadResponse , 'response line too long'
163- end
164- else
165- # net-protocol without Net::BufferedIO#readuntil limit support
166- def read_line ( sock , limit , ignore_eof = false ) #:nodoc: internal use only
167- sock . readuntil ( "\n " , ignore_eof )
168- end
158+ def read_line ( sock , limit , ignore_eof = false ) #:nodoc: internal use only
159+ sock . readuntil ( "\n " , ignore_eof , limit : limit )
160+ rescue Net ::ReadLimitExceeded
161+ raise Net ::HTTPBadResponse , 'response line too long'
169162 end
170163
171164 private
Original file line number Diff line number Diff line change @@ -35,5 +35,6 @@ Gem::Specification.new do |spec|
3535 spec . bindir = "exe"
3636 spec . require_paths = [ "lib" ]
3737
38+ spec . add_dependency "net-protocol" , ">= 0.3.0"
3839 spec . add_dependency "uri" , ">= 0.11.1"
3940end
Original file line number Diff line number Diff line change @@ -44,23 +44,20 @@ def test_response_header_within_limit
4444 end
4545
4646 def test_status_line_too_long
47- omit 'requires Net::BufferedIO#readuntil limit support' unless defined? ( Net ::ReadLimitExceeded )
4847 io = endless_io ( "HTTP/1.1 200 " )
4948 assert_raise ( Net ::HTTPBadResponse ) do
5049 Net ::HTTPResponse . read_new ( io )
5150 end
5251 end
5352
5453 def test_response_header_line_too_long
55- omit 'requires Net::BufferedIO#readuntil limit support' unless defined? ( Net ::ReadLimitExceeded )
5654 io = endless_io ( "HTTP/1.1 200 OK\n X-Foo: " )
5755 assert_raise ( Net ::HTTPBadResponse ) do
5856 Net ::HTTPResponse . read_new ( io )
5957 end
6058 end
6159
6260 def test_chunk_size_line_too_long
63- omit 'requires Net::BufferedIO#readuntil limit support' unless defined? ( Net ::ReadLimitExceeded )
6461 io = endless_io ( "HTTP/1.1 200 OK\n Transfer-Encoding: chunked\n \n " )
6562 res = Net ::HTTPResponse . read_new ( io )
6663 assert_raise ( Net ::HTTPBadResponse ) do
@@ -71,7 +68,6 @@ def test_chunk_size_line_too_long
7168 end
7269
7370 def test_chunk_trailer_line_too_long
74- omit 'requires Net::BufferedIO#readuntil limit support' unless defined? ( Net ::ReadLimitExceeded )
7571 io = endless_io ( "HTTP/1.1 200 OK\n Transfer-Encoding: chunked\n \n 0\n " )
7672 res = Net ::HTTPResponse . read_new ( io )
7773 assert_raise ( Net ::HTTPBadResponse ) do
You can’t perform that action at this time.
0 commit comments