headers, stream = encode_response(content, text, html, json)
self._prepare(headers)
self.stream = stream
- if content is None or isinstance(content, bytes):
+ if content is None or isinstance(content, (bytes, str)):
# Load the response body, except for streaming content.
self.read()
assert not response.is_error
+def test_response_content():
+ response = httpx.Response(200, content="Hello, world!")
+
+ assert response.status_code == 200
+ assert response.reason_phrase == "OK"
+ assert response.text == "Hello, world!"
+ assert response.headers == httpx.Headers(
+ {
+ "Content-Length": "13",
+ }
+ )
+
+
def test_response_text():
response = httpx.Response(200, text="Hello, world!")