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

Set correct Content-Type header in query response #4828

Merged
merged 3 commits into from
Nov 26, 2021
Merged

Conversation

chaudum
Copy link
Contributor

@chaudum chaudum commented 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

$ curl -vGET http://localhost:3100/loki/api/v1/query_range --data-urlencode 'query={app="app"}' 
*   Trying 127.0.0.1:3100...
* Connected to localhost (127.0.0.1) port 3100 (#0)
> GET /loki/api/v1/query_range?query=%7Bapp%3D%22app%22%7D HTTP/1.1
> Host: localhost:3100
> User-Agent: curl/7.79.1
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: application/json; charset=UTF-8
< Date: Thu, 25 Nov 2021 21:15:13 GMT
< Content-Length: 735
< 

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>
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
@chaudum chaudum marked this pull request as ready for review November 26, 2021 08:40
@chaudum chaudum requested a review from a team as a code owner November 26, 2021 08:40
Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cyriltovena cyriltovena merged commit 7f54641 into main Nov 26, 2021
@cyriltovena cyriltovena deleted the chaudum/issue-4791 branch November 26, 2021 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wrong conten-type in /loki/api/v1/query http responses
2 participants