MCPcopy
hub / github.com/encode/httpx / print_response

Function print_response

httpx/_main.py:170–186  ·  view source on GitHub ↗
(response: Response)

Source from the content-addressed store, hash-verified

168
169
170def print_response(response: Response) -> None:
171 console = rich.console.Console()
172 lexer_name = get_lexer_for_response(response)
173 if lexer_name:
174 if lexer_name.lower() == "json":
175 try:
176 data = response.json()
177 text = json.dumps(data, indent=4)
178 except ValueError: # pragma: no cover
179 text = response.text
180 else:
181 text = response.text
182
183 syntax = rich.syntax.Syntax(text, lexer_name, theme="ansi_dark", word_wrap=True)
184 console.print(syntax)
185 else:
186 console.print(f"<{len(response.content)} bytes of binary data>")
187
188
189_PCTRTT = typing.Tuple[typing.Tuple[str, str], ...]

Callers 1

mainFunction · 0.85

Calls 2

get_lexer_for_responseFunction · 0.85
jsonMethod · 0.80

Tested by

no test coverage detected