Skip to content

Drop .next()/.anext() in favour of response.next_request - #1339

Merged
lovelydinosaur merged 4 commits into
masterfrom
drop-next-anext
Oct 6, 2020
Merged

Drop .next()/.anext() in favour of response.next_request#1339
lovelydinosaur merged 4 commits into
masterfrom
drop-next-anext

Conversation

@lovelydinosaur

Copy link
Copy Markdown
Contributor

See also #1334

Our .next() interface was intended to provide parity with requests, but actually provides the wrong API.

Dropping I/O methods from the Response class is surely a good thing to do if we can, and I'd far rather we had a simple request instance stored on the model instance, than a partially bound function call.

Using allow_redirects=False and explicitly following redirects now looks like this:

client=httpx.Client()
request=client.build_request("GET", ...)
whilerequestisnotNone:
response=client.send(request, allow_redirects=False)
request=response.next_request

@lovelydinosaurlovelydinosaur added the requests-compat Issues related to Requests backwards compatibility label Oct 2, 2020
@lovelydinosaurlovelydinosaur added this to the v0.16 milestone Oct 2, 2020

@florimondmancaflorimondmanca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superb 👍

@jcugatjcugat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we're ok doing this breaking change pre-1.0 right?

@StephenBrown2

Copy link
Copy Markdown
Contributor

I guess we're ok doing this breaking change pre-1.0 right?

Since it's meant for requests compatibility, I'd say yes.

@lovelydinosaurlovelydinosaur mentioned this pull request Oct 6, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requests-compatIssues related to Requests backwards compatibility

Development

Successfully merging this pull request may close these issues.

4 participants

@lovelydinosaur@StephenBrown2@jcugat@florimondmanca