File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed
Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -300,13 +300,16 @@ def _print_response_debug_info(response):
300300 """
301301 # these come back as ints, convert to HTTP version
302302 http_version = response .raw .version / 10
303+ body = response .content .decode ("utf-8" , errors = "replace" )
303304
304305 print (
305306 f"< HTTP/{ http_version :.1f} { response .status_code } { response .reason } " ,
306307 file = sys .stderr ,
307308 )
308309 for k , v in response .headers .items ():
309310 print (f"< { k } : { v } " , file = sys .stderr )
311+ print ("< Body:" , file = sys .stderr )
312+ print ("< " , body or "" , file = sys .stderr )
310313 print ("< " , file = sys .stderr )
311314
312315
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ def test_response_debug_info(self):
2828 status_code = 200 ,
2929 reason = "OK" ,
3030 headers = {"cool" : "test" },
31+ content = b"cool body" ,
3132 )
3233
3334 with contextlib .redirect_stderr (stderr_buf ):
@@ -36,6 +37,9 @@ def test_response_debug_info(self):
3637 output = stderr_buf .getvalue ()
3738 assert "< HTTP/1.1 200 OK" in output
3839 assert "< cool: test" in output
40+ assert "< Body:" in output
41+ assert "< cool body" in output
42+ assert "< " in output
3943
4044 def test_request_debug_info (self ):
4145 stderr_buf = io .StringIO ()
You can’t perform that action at this time.
0 commit comments