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 {
59
59
// copy back from the hyper body to the ruby string; doesn't need to be performant,
60
60
// only used in tests
61
61
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
+ }
65
69
}
66
70
}
Original file line number Diff line number Diff line change @@ -64,12 +64,12 @@ def test_unix_socket_cleans_up_socket
64
64
end
65
65
end
66
66
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
73
73
74
74
def with_server ( request_handler , &block )
75
75
server = HyperRuby ::Server . new
Original file line number Diff line number Diff line change @@ -12,4 +12,11 @@ def test_can_read_properties_back
12
12
assert_equal 'Hello, world!' , response . body
13
13
end
14
14
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
+
15
22
end
You can’t perform that action at this time.
0 commit comments