File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 181181 end
182182
183183 it "fails with HTTP/1.0 request with transfer-encoding and content-length" do
184- client . stream . write "GET / HTTP/1.0\r \n Host: localhost\r \n Content-Length: 11\r \n Transfer-Encoding: chunked\r \n \r \n Hello World"
184+ client . stream . write "GET / HTTP/1.0\r \n Host: localhost\r \n Connection: keep-alive \r \ n Content-Length: 11\r \n Transfer-Encoding: chunked\r \n \r \n Hello World"
185185 client . stream . close
186186
187187 expect do
626626 end
627627 end
628628
629+ with "#read_body" do
630+ # Callers using the original signature do not pass a version, so framing must still be validated without it.
631+ it "reads chunked request body without a version" do
632+ body = server . read_body ( { "transfer-encoding" => [ "chunked" ] } , false )
633+
634+ expect ( body ) . to be_a ( Protocol ::HTTP1 ::Body ::Chunked )
635+ expect ( server ) . to be ( :persistent )
636+ end
637+
638+ it "fails with non-chunked request transfer-encoding without a version" do
639+ expect do
640+ server . read_body ( { "transfer-encoding" => [ "gzip" ] } , false )
641+ end . to raise_exception ( Protocol ::HTTP1 ::BadRequest , message : be =~ /must be chunked/ )
642+
643+ expect ( server ) . not . to be ( :persistent )
644+ end
645+
646+ it "reads non-chunked response transfer-encoding until closed without a version" do
647+ body = client . read_body ( { "transfer-encoding" => [ "gzip" ] } , true )
648+
649+ expect ( body ) . to be_a ( Protocol ::HTTP1 ::Body ::Remainder )
650+ expect ( client ) . not . to be ( :persistent )
651+ end
652+ end
653+
629654 with "#write_chunked_body" do
630655 let ( :chunks ) { [ "Hello" , "World" ] }
631656 let ( :body ) { ::Protocol ::HTTP ::Body ::Buffered . wrap ( chunks ) }
You can’t perform that action at this time.
0 commit comments