forwardemail / forwardemail/superagent

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

Open
#1,459 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
16.6k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.