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

How to handle Expect: 100-continue? #140

Open
joneshf opened this issue May 17, 2019 · 2 comments
Open

How to handle Expect: 100-continue? #140

joneshf opened this issue May 17, 2019 · 2 comments

Comments

@joneshf
Copy link
Contributor

joneshf commented May 17, 2019

I'm trying to handle Expect headers and I'm unsure if it's possible with httpure:

An origin server MUST, upon receiving an HTTP/1.1 (or later)
request-line and a complete header section that contains a
100-continue expectation and indicates a request message body will
follow, either send an immediate response with a final status code,
if that status can be determined by examining just the request-line
and header fields, or send an immediate 100 (Continue) response to
encourage the client to send the request's message body. The origin
server MUST NOT wait for the message body before sending the 100
(Continue) response.

It seems that since there's no listener on 'checkContinue' (purescript-node-http doesn't expose or handle the event and it doesn't look like anything is happening in this package), the underlying http module will always respond with 100 Continue and process the request. Is that right?

If so, can we add something to allow us to decide whether or not to respond with 100 Continue or some other code based on the request headers alone? E.g. if a client sends:

> POST /foo HTTP/1.1
> Content-Type: application/json
> Expect: 100-continue

And we know we cannot handle JSON, how do we respond with a 415 Unsupported Media Type? Or if a client sends:

> POST /foo HTTP/1.1
> Content-Length: 123456789012345
> Expect: 100-continue

And we know we're not going to handle giant requests, how would we respond with 413 Payload Too Large?

If we can add something that allows handling Expect: 100-continue, how would we send the 100 Continue line without closing the connection but reading the request? The model of httpure seems to be that you already have an HTTPure.Request.Request (with a body), and that you're working with that. Is there another way to handle things?

@cprussin
Copy link
Collaborator

Hmm, so I expect (heh, see what I did there?) that this would be covered by implementing streaming requests (see #63). I keep bumping that because I haven't really thought of an API that I particularly like, but I'm open to ideas.

Out of curiosity, what's the priority here? Is it mostly to be spec-compliant? I definitely think that this is something we should ideally support, but as it's a somewhat less-used part of the spec and it seems like support across servers and clients in the wild is pretty shotty anyways, I'm wondering if it's worth prioritizing the effort in httpure.

@joneshf
Copy link
Contributor Author

joneshf commented May 21, 2019

Hmm, streaming the request does seem like it might help deal with this. More than happy to put in some work once an API is settled.

It is spec-compliance–as I'm wanting to build something on top of httpure–but it's not quite that obscure. For instance, if you curl something larger than 1024 bytes, it sends an Expect: 100-continue header and acts accordingly. So long as the underlying node implementation will at least respond to that header we won't lose requests, but it would be nice to be able to control this when need be. So prioritize accordingly.

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

No branches or pull requests

2 participants