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

HEAD requests return a response body when pretty=true #21075

Closed
gmarz opened this issue Oct 21, 2016 · 6 comments
Closed

HEAD requests return a response body when pretty=true #21075

gmarz opened this issue Oct 21, 2016 · 6 comments
Assignees
Labels
blocker >bug :Core/Infra/REST API REST infrastructure and utilities v5.0.0

Comments

@gmarz
Copy link
Contributor

gmarz commented Oct 21, 2016

Elasticsearch version: 5.0.0-rc1

Elasticsearch returns a response body when pretty=true is specified on a HEAD request which violates the HTTP 1.1 specification

HEAD http://127.0.0.1:9200/?pretty=true 
HTTP/1.1 200 OK
content-type: application/json; charset=UTF-8
content-length: 1


This causes a problem within the .NET client, which conforms strictly to the HTTP 1.1 spec.

@gmarz gmarz added the :Distributed/Network Http and internode communication implementations label Oct 21, 2016
@nik9000 nik9000 added :Core/Infra/REST API REST infrastructure and utilities >bug blocker v5.0.0 and removed :Distributed/Network Http and internode communication implementations labels Oct 21, 2016
@nik9000 nik9000 self-assigned this Oct 21, 2016
@jasontedor
Copy link
Member

Additionally, the header is wrong. From RFC 2616:

The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET.

@jasontedor
Copy link
Member

We have a short-term fix for REST main action that will address this issue so that there is not a body. We have a plan to address all HEAD methods as a future follow up (so that the content-length header is correct). There will be a PR from @nik9000 shortly.

nik9000 added a commit to nik9000/elasticsearch that referenced this issue Oct 21, 2016
Before this commit `curl -XHEAD localhost:9200?pretty` would return
`Content-Length: 1` and a body which is fairly upsetting to standards
compliant tools. Now it'll return `Content-Length: 0` with an empty
body like every other `HEAD` request.

Relates to elastic#21075
@nik9000
Copy link
Member

nik9000 commented Oct 21, 2016

I've opened the short term workaround (#21077) and we'll repurpose this issue for the long term, fully rfc compliant fix.

nik9000 added a commit that referenced this issue Oct 21, 2016
Before this commit `curl -XHEAD localhost:9200?pretty` would return
`Content-Length: 1` and a body which is fairly upsetting to standards
compliant tools. Now it'll return `Content-Length: 0` with an empty
body like every other `HEAD` request.

Relates to #21075
@jasontedor
Copy link
Member

We'll open a new issue for the content-length piece and relate it here.

@jasontedor
Copy link
Member

Closed by #21077

nik9000 added a commit that referenced this issue Oct 21, 2016
Before this commit `curl -XHEAD localhost:9200?pretty` would return
`Content-Length: 1` and a body which is fairly upsetting to standards
compliant tools. Now it'll return `Content-Length: 0` with an empty
body like every other `HEAD` request.

Relates to #21075
nik9000 added a commit that referenced this issue Oct 21, 2016
Before this commit `curl -XHEAD localhost:9200?pretty` would return
`Content-Length: 1` and a body which is fairly upsetting to standards
compliant tools. Now it'll return `Content-Length: 0` with an empty
body like every other `HEAD` request.

Relates to #21075
@jasontedor
Copy link
Member

We'll open a new issue for the content-length piece and relate it here.

Partially addressed in #21123.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker >bug :Core/Infra/REST API REST infrastructure and utilities v5.0.0
Projects
None yet
Development

No branches or pull requests

3 participants