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

Using send() with get() might cause requests to be rejected #1459

Open
marcellobarile opened this issue Feb 15, 2019 · 0 comments
Open

Using send() with get() might cause requests to be rejected #1459

marcellobarile opened this issue Feb 15, 2019 · 0 comments

Comments

@marcellobarile
Copy link
Contributor

marcellobarile commented Feb 15, 2019

Preface:
From https://tools.ietf.org/html/rfc7230
"A user agent SHOULD NOT send a Content-Length header field when the request message does not contain a payload body and the method semantics do not anticipate such a body."

The issue:
Even if the following thing would be (logically) incorrect, it's still allowed to be done:

// ...
request
   .get('http://www.google.com')
   .send({foo: 'bar'})
// ...

In this case, the payload passed to the "send" method will not be converted into a query string, and the "content-length" header will be added to the GET request.
This might cause the request to be rejected by web services.

The issue is reproduced here: https://repl.it/@MarcelloBarile/superagent-content-length

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

1 participant