-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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) #711
Comments
Taking it further: Enable HTTP verb actions on links. Think: Chained request/response! |
I've been thinking about something like this for a long time. If the API was kept this simple, I think we could keep this directly in Requests. |
|
HAL is now an Internet-Draft. This is likely to become the hypermedia guideline for expressing connections between resources (what the Link header does) with many more features. Also @mitsuhiko expressed his hate for embedding "new things" into headers. I think it might have something to do with cachability or intermediaries that mess with headers. See more: |
One of the reasons people don't use Link headers is the lack of tooling, so I'd love to see this in Requests, for obvious reasons.
HAL is described my mike as "HTML for machines," so I think this description is slightly off. That said, I don't see why it's relevant to this discussion, exactly, so I should just shut up. :) |
One thought..
should return the URI, rather than the raw data. We already have means of accessing headers. |
@steveklabnik I suppose Link headers aren't going anywhere just because of HAL. One question you might be more familiar with .. is the rel attribute a namespace of sorts for links? So suppose you had two ;rel=profile headers should one of them be ignored? I'm asking because the implementation would be nice as an attribute accessor like so:
HTML pages can link to multiple stylesheets, as is common. |
@jokull this is quickly getting off topic, and this might be a great question for the hypermedia@librelist.com list, but quickly: Not so much a namespace as like a tag. Think about a collection: <ul class="collection">
<li><a rel="item current" href="...">one</a>
<li><a rel="item" href="...">two</a>
<li><a rel="item" href="...">three</a>
</ul> Each one is an You could easily have it return an array rather than a string. Note that non-standard link relations are supposed to be URIs, so accessing it via a method (sorry, Rubyist here primarily) means that when I have <a href="..." rel="http://mysite.com/rels/blog-post">Links are awesome</a> you're not gonna be able to use this interface to get |
Requests doesn't want to be involved with anything in the response body. Only headers. |
Link Relations work on any link, link header or in the response body. The issue is the same: two Link headers with an |
@kennethreitz Good point about headers vs body. Are you looking for contributors or suggested implementations? One more reference: the official Link Relations. |
This is happening now.
|
Oh it is so happening. |
I guess it’s a MultiDict with |
A happier man today, I could not be. ✨ 🍰 ✨ |
f3159ed handles basic functionality |
Added in a link handler as per issue #711
Very handy, thank you. :-) ❤️ |
Web Linking RFC
GitHub uses these for pagination in their API for example. Potentially they make API’s more self describing and discoverable.
I’d like to invite the discussion of requests making an effort to consume these and expose them on
Response.links
as a dictionary or dict-like object.A HTTP Link header looks like this:
It’d be cool to access the links like so
Maybe this belongs in a
requests-hypermedia
library.References:
The text was updated successfully, but these errors were encountered: