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

Always set the Content-Length header for requests with a body #41

Merged
merged 1 commit into from
Oct 21, 2017

Conversation

subodhkhanduri1
Copy link
Contributor

AWS requires the Content-Length header when the body is sent, otherwise the request signature will not match.
Elasticsearch.js does not set a Content-Length header for request bodies of DELETE requests.
Since this is a requirement for requests to AWS, the connector should take up that responsibility.

Fixes #19

AWS  requires the Content-Length header when the body is sent, otherwise the request signature will not match.
Elasticsearch.js does not set a Content-Length header for request bodies of DELETE requests.
Since this is a requirement for requests to AWS, the connector should take up that responsibility.
@ajkerr
Copy link

ajkerr commented Oct 4, 2017

I'm not sure that the fix belongs in this module, although it will work as a workaround.

@subodhkhanduri1
Copy link
Contributor Author

The request is generated by elasticsearch.js and http-aws-es performs the necessary steps to get it ready for AWS. The HTTP request handler of aws-sdk only uses the ready request to send it.

Even for AWS Cloudsearch, the Content-Length is set by the module that generates the request(the interface object).

https://github.com/aws/aws-sdk-js/blob/4c768539749f4c3056d30a58fa0ddba28df5504c/lib/services/cloudsearchdomain.js#L107

@ajkerr
Copy link

ajkerr commented Oct 4, 2017

@subodhkhanduri1 Good point. There's definitely some inconsistency in the SDK on when Content-Length is set automatically and when it isn't. I'd be happy with this patch to get things working.

@TheDeveloper TheDeveloper merged commit a8136db into TheDeveloper:master Oct 21, 2017
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 this pull request may close these issues.

3 participants