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

Invert Request API #222

Closed
chadwhitacre opened this issue Sep 6, 2013 · 13 comments · Fixed by #576
Closed

Invert Request API #222

chadwhitacre opened this issue Sep 6, 2013 · 13 comments · Fixed by #576
Assignees

Comments

@chadwhitacre
Copy link
Contributor

The current design of the verbose Request API has higher-order objects (Mappings, etc.) as the base value such as request.line.uri.path, with raw bytes in a .raw attribute. This is confusing. Rather, all objects representing a fundamental part of an HTTP message should be a bytes subclass, with higher-order objects available as attributes.

@chadwhitacre
Copy link
Contributor Author

We'll want to roughly specify the whole API before we dive in, but as a note I'm thinking that we'll move wildcards from path into path.parts (alongside the int indexes there). See #188 and IRC.

@pjz
Copy link
Contributor

pjz commented Sep 16, 2013

Are you looking to have this also fix #13 ?

@chadwhitacre chadwhitacre mentioned this issue Sep 2, 2014
36 tasks
@chadwhitacre chadwhitacre changed the title turn request API inside out revisit Request/Response API design Sep 2, 2014
@chadwhitacre
Copy link
Contributor Author

call

@pjz pjz mentioned this issue Sep 1, 2015
@pjz
Copy link
Contributor

pjz commented Sep 1, 2015

(around 0:32:00 to 0:35:00 in the above call, ICYC)

@chadwhitacre
Copy link
Contributor Author

!m @pjz

@chadwhitacre chadwhitacre mentioned this issue Nov 5, 2015
@chadwhitacre
Copy link
Contributor Author

Closing in favor of #526.

@chadwhitacre
Copy link
Contributor Author

I really do like that requests print as HTTP messages. I suppose HTTP/2 mucks with that, and of course WSGI is lossy so this isn't guaranteed the same as what's on the wire.

(Pdb) print request
GET /~whit537/settings/close HTTP/1.1
Accept-Language: en-US,en;q=0.8
Accept-Encoding: gzip, deflate, sdch
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36
Host: localhost:8537
Cookie: []
Referer: http://localhost:8537/~whit537/settings/
Upgrade-Insecure-Requests: 1


(Pdb)

@chadwhitacre
Copy link
Contributor Author

@Changaco at #357 (comment):

If we have enough time we should try to take care of #222 before 1.0.

Do you have enough to go on to get started on this?

@Changaco
Copy link
Member

Changaco commented Sep 9, 2016

Do you have enough to go on to get started on this?

It would be useful to clarify the problem(s) we're trying to fix, and whether we're okay with making lots of breaking changes or if we should try to maintain backward compatibility wherever possible.

@chadwhitacre
Copy link
Contributor Author

chadwhitacre commented Sep 9, 2016

The problem is the confusion of wondering what type request.line.uri.path is. The suggested solution is that the names representing parts of an HTTP message always be bytes, with higher-order representations of those parts in attributes on the parts.

request.line.uri.path is currently a Mapping.

The proposal here is that request.line.uri.path be bytes, with request.line.uri.path.parts as the Mapping.

@Changaco
Copy link
Member

I meant: is this issue only about fixing a small confusion, or do we actually want to completely revisit both the Request and Response APIs as the issue's title suggests?

@Changaco
Copy link
Member

Regarding the Response class, I think we should kill the raise Response(...) pattern. Instead of creating new response objects everywhere, we should only use the one in the state. That would allow us to give it access to the website and request objects, and thus provide a richer API.

@chadwhitacre chadwhitacre changed the title revisit Request/Response API design Invert Request API Sep 12, 2016
@chadwhitacre
Copy link
Contributor Author

we should only use the one in the state

So that is what return response(400, 'xxx') is about. ;-) That looks a lot like the WSGI API, with request, response instead of environ, start_response.

do we actually want to completely revisit both the Request and Response APIs as the issue's title suggests?

That sounds like a deep rabbit hole. I've narrowed the scope of this ticket. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants