File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ def dump_headers(headers)
6363
6464 def dump_body ( body )
6565 if body . respond_to? ( :to_str )
66- body . to_str
66+ body . to_str . encode ( Encoding :: UTF_8 , undef : :replace , invalid : :replace )
6767 else
6868 pretty_inspect ( body )
6969 end
Original file line number Diff line number Diff line change 2121 stubs . post ( '/ohai' ) { [ 200 , { 'Content-Type' => 'text/html' } , 'fred' ] }
2222 stubs . post ( '/ohyes' ) { [ 200 , { 'Content-Type' => 'text/html' } , 'pebbles' ] }
2323 stubs . get ( '/rubbles' ) { [ 200 , { 'Content-Type' => 'application/json' } , rubbles ] }
24+ stubs . get ( '/8bit' ) { [ 200 , { 'Content-Type' => 'text/html' } , ( +'café!' ) . force_encoding ( Encoding ::ASCII_8BIT ) ] }
2425 stubs . get ( '/filtered_body' ) { [ 200 , { 'Content-Type' => 'text/html' } , 'soylent green is people' ] }
2526 stubs . get ( '/filtered_headers' ) { [ 200 , { 'Content-Type' => 'text/html' } , 'headers response' ] }
2627 stubs . get ( '/filtered_params' ) { [ 200 , { 'Content-Type' => 'text/html' } , 'params response' ] }
@@ -238,6 +239,11 @@ def response(_env)
238239 expect ( string_io . string ) . to match ( %(fred) )
239240 end
240241
242+ it 'converts to UTF-8' do
243+ conn . get '/8bit'
244+ expect ( string_io . string ) . to match ( %(caf��!) )
245+ end
246+
241247 after do
242248 described_class . default_options = { bodies : false }
243249 end
You can’t perform that action at this time.
0 commit comments