-
Notifications
You must be signed in to change notification settings - Fork 193
Come up with an API for 1XX responses. #71
Comments
I don't know the draft well enough. Let me go read that and then I'll come back with ideas. |
Yea same... I'd love to see some potential code examples of what such an API might look like, and give feedback on that. :) |
I don't see any references to 100-continue in the draft linked in #68. Will it work the same way as it does in HTTP/1.1 where it is an interim (non-authoritative) response? If that's the case, I'm not sure we need a special API but I also don't think we should swallow/ignore it like I wonder if an improvement would involve stealing The advantage to this way of doing this way is that the API is kept simple and flexible. Meanwhile, I'm unsure how to represent to the user that it received a |
Yeah, 1XX is not special in HTTP/2, it behaves exactly as it does in HTTP/1.1. This is therefore an opportunity for us to work out how we'd like provisional responses to work. First, note that One API option is to have the user handle the # Build the request but don't send any body data.
c = HTTP20Connection('google.com:443')
c.putrequest('POST', '/some_endpoint')
c.putheader('Content-Type', 'application/octet-stream')
c.putheader('Content-Length', len(big_data))
c.endheaders()
# Wait for a provisional response for 5 seconds.
resp = c.getresponse(timeout=5)
if resp is None or resp.status == 100:
c.send(big_data)
else:
# Handle final status code, probably an error. This method has the advantage of allowing for other 1XX status codes, but forces the user to manage the entire flow. I don't know that that's a problem for me. We'd need to rework |
Not to be a pain, but I assume you also meant to include I think this design would work fine for anyone using hyper directly. I guess |
I did, yeah. =P I think that's correct. Hyper's job is really to make it possible to handle provisional responses, whereas urllib3's job may be to abstract them away. Does that seem reasonable, @shazow? (A side note: we can also handle trailers, which are headers that come after a chunked body has been received. Right now they're just transparently merged with the original headers, but it might be better to provide an alternate way to receive them. Any preferences?) |
Yea sounds like a decent low-level interface, we can always add more abstractions on top of it. |
Maybe combined headers live in |
I was thinking along the same lines, but was thinking of only having |
So they would not be combined? I guess that can work.
|
Sorry that wasn't clear. |
How does excluding work if there are duplicates? I'd keep them separate.
|
I think the trailers and headers are logically a single header block. This means you should only be able to duplicate headers that can be represented as comma-separated lists (and the Set-Cookie header). With that said, I'd be leaning towards having headers and trailers separate, and then have a simple property that combines them. |
There will always be that one edge case where having the original format is
|
So |
Maybe. My issue there is that for non-expert users For that matter, it seems like trailers are treated conceptually as part of the headers for a request. That's weird: they aren't headers in any sense. Here's another question: if you request the equivalent of This entire discussion makes me want to back away from ever showing the combined set, and to simply have |
I think that API seems best. |
+1, have higher level libs merge them. On Tue, Aug 12, 2014 at 8:30 AM, Ian Cordasco notifications@github.com
|
Further thought on this makes me wonder whether the c = HTTPConnection('somefileuploadsite.com')
c.request('POST', '/myfile', body=massive_file, expect_continue=True)
r = c.get_response()
assert r.status_code == 200 Under the covers, The advantage of this API is that the user doesn't need to worry about the exact semantics of the 100 response. All other provisional responses will be returned as normal, and the user will (as normal) be allowed/expected to retrieve the socket object if they need it. |
So, here's the fun thing. The spec (last I checked) said to wait for a |
Ooh, that's a good idea. It'll also allow for |
This is not something
httplib
supports, so we have nowhere to take our lead from. This means we can do this right (or at least right-ish).So what's our idealised API? /cc @sigmavirus24 for his brains, @shazow as the likely primary consumer of the API.
The text was updated successfully, but these errors were encountered: