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

wrong conten-type in /loki/api/v1/query http responses #4791

Closed
gabor opened this issue Nov 19, 2021 · 0 comments · Fixed by #4828
Closed

wrong conten-type in /loki/api/v1/query http responses #4791

gabor opened this issue Nov 19, 2021 · 0 comments · Fixed by #4828
Assignees

Comments

@gabor
Copy link
Contributor

gabor commented Nov 19, 2021

Describe the bug
when i query the /loki/api/v1/query endpoint, the response body is correct, but the content-type header says text/plain; charset=utf-8 . it should be application/json.

To Reproduce
Steps to reproduce the behavior:

  1. Started Loki using the docker image: docker run -p 3100:3100 grafana/loki:2.4.1
  2. run any query using the /loki/api/v1/query endpoint
  3. the response has this http header: Content-Type: text/plain; charset=utf-8

Expected behavior
the response should have this http header: Content-Type: application/json; charset=UTF-8

Environment:

  • nothing special, running docker on mac-os

NOTE: it returns the correct Content-Type: application/json; charset=UTF-8 header when running with the version 2.3.0 docker image.

@chaudum chaudum self-assigned this Nov 25, 2021
chaudum added a commit that referenced this issue Nov 25, 2021
Because the internal query request handlers did not set the response
content type explicitly to `application/json`, and the external request
handler takes the response content type from the internal response to
set it for the resulting HTTP response, that response was also
incorrectly returning `Content-Type: text/plain`.

Setting the content type in the internal response correctly results in
the expected `Content-Type` header `application/json; charset=UTF-8`.

Fixes #4791

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
cyriltovena pushed a commit that referenced this issue Nov 26, 2021
* Set correct `Content-Type` header in query response

Because the internal query request handlers did not set the response
content type explicitly to `application/json`, and the external request
handler takes the response content type from the internal response to
set it for the resulting HTTP response, that response was also
incorrectly returning `Content-Type: text/plain`.

Setting the content type in the internal response correctly results in
the expected `Content-Type` header `application/json; charset=UTF-8`.

Fixes #4791

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>

* fixup! Set correct `Content-Type` header in query response

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>

* fixup! fixup! Set correct `Content-Type` header in query response

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
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 a pull request may close this issue.

2 participants