Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse link headers (rfc5988) #2948

Closed
daniel-j-h opened this issue Apr 22, 2018 · 7 comments
Closed

Parse link headers (rfc5988) #2948

daniel-j-h opened this issue Apr 22, 2018 · 7 comments

Comments

@daniel-j-h
Copy link

See psf/requests#711 for context.

It would be great if aiohttp could parse link headers helping e.g. with pagination.

At the moment the ClientResponse has a headers attribute from which we can get the link header:

print(response.headers.get('Link'))

<https://example.com//page/3>; rel="next", <https://example.com/page/1>; rel="prev"

But it's of type str and not parsed. To use the url e.g. in the next rel (for pagination) users currently have to parse the link header string manually pulling out the url.

@asvetlov
Copy link
Member

The attached issue has no design for the API, only many good wishes.

Would you elaborate your vision?

@daniel-j-h
Copy link
Author

I'm not too deep into aiohttp - I was just using it for a small app and found out about the missing link header parsing; so I don't have clear real vision. The API I am familiar with is the requests API for link headers:

http://docs.python-requests.org/en/master/user/advanced/#link-headers

I think we need to make two calls here:

  1. Should aiohttp do link header parsing or should users use an external library for it?
  2. Should aiohttp replicate the requests API for link headers?

@asvetlov
Copy link
Member

Well, supporting response.links['name'] sounds a good addition.

@asvetlov
Copy link
Member

Any volunteer?

@hdk5
Copy link
Contributor

hdk5 commented Apr 24, 2018

I'll do it

@asvetlov
Copy link
Member

Fixed by #2955

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants