File tree Expand file tree Collapse file tree 3 files changed +20
-9
lines changed
Expand file tree Collapse file tree 3 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -59,8 +59,12 @@ impl Response {
5959 // copy back from the hyper body to the ruby string; doesn't need to be performant,
6060 // only used in tests
6161 let body = self . response . body ( ) ;
62- let frame = body. clone ( ) . frame ( ) . now_or_never ( ) . unwrap ( ) . unwrap ( ) . unwrap ( ) ;
63- let data_chunk = frame. into_data ( ) . unwrap ( ) ;
64- RString :: from_slice ( data_chunk. iter ( ) . as_slice ( ) )
62+ match body. clone ( ) . frame ( ) . now_or_never ( ) {
63+ Some ( frame) => {
64+ let data_chunk = frame. unwrap ( ) . unwrap ( ) . into_data ( ) . unwrap ( ) ;
65+ RString :: from_slice ( data_chunk. iter ( ) . as_slice ( ) )
66+ }
67+ None => RString :: buf_new ( 0 ) ,
68+ }
6569 }
6670}
Original file line number Diff line number Diff line change @@ -64,12 +64,12 @@ def test_unix_socket_cleans_up_socket
6464 end
6565 end
6666
67- def test_blocking
68- buffer = String . new ( capacity : 1024 )
69- with_server ( -> ( request ) { handler_accept ( request , buffer ) } ) do |client |
70- gets
71- end
72- end
67+ # def test_blocking
68+ # buffer = String.new(capacity: 1024)
69+ # with_server(-> (request) { handler_accept(request, buffer) }) do |client|
70+ # gets
71+ # end
72+ # end
7373
7474 def with_server ( request_handler , &block )
7575 server = HyperRuby ::Server . new
Original file line number Diff line number Diff line change @@ -12,4 +12,11 @@ def test_can_read_properties_back
1212 assert_equal 'Hello, world!' , response . body
1313 end
1414
15+ def test_can_read_property_with_empty_body
16+ response = HyperRuby ::Response . new ( 200 , { 'Content-Type' => 'text/plain' } , '' )
17+ assert_equal 200 , response . status
18+ assert_equal 'text/plain' , response . headers [ 'content-type' ]
19+ assert_equal '' , response . body
20+ end
21+
1522end
You can’t perform that action at this time.
0 commit comments