Skip to content
Myr

building Response manually

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nate Prewitt · committed by Nate Prewitt · parent e50c61b · Browse files · 1 file+7 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+7 added−2 removed

  • tests:+7 added−2 removed

1 file+7 added−2 removed

modified:tests/test_requests.py+7 added-2 removed
242 unmodified lines
243 ses = requests.Session()244 req = requests.Request('POST', httpbin('post'), data=(b'x' for x in range(1)))245 prep = ses.prepare_request(req)246 assert 'Transfer-Encoding' in prep.headers247 resp = ses.send(prep)247248 # Create Response to avoid https://github.com/kevin1024/pytest-httpbin/issues/33249 resp = requests.Response()250 resp.raw = io.BytesIO(b'the content')251 resp.request = prep252 setattr(resp.raw, 'release_conn', lambda *args: args)253254 # Mimic a redirect response255 resp.status_code = 302251 resp.headers['location'] = 'get'256 resp.headers['location'] = httpbin('get')257258 # Run request through resolve_redirect259 next_resp = next(ses.resolve_redirects(resp, prep))260 assert next_resp.request.body is None
1555 unmodified lines