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 Content-Type header in response #1

Merged
merged 1 commit into from
Mar 17, 2017
Merged

Set Content-Type header in response #1

merged 1 commit into from
Mar 17, 2017

Conversation

hkjn
Copy link
Contributor

@hkjn hkjn commented Mar 17, 2017

Since we return JSON, we should set Content-Type=application/json.

This messes up some monitoring we have, since it receives the default Content-Type: text/plain; charset=utf-8 currently, and expects only JSON for its health checks.

Tested by building and running sample program before/after change.

Before

curl -v http://localhost:8077/healthcheck
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8077 (#0)
> GET /healthcheck HTTP/1.1
> Host: localhost:8077
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 17 Mar 2017 10:05:54 GMT
< Content-Length: 117
< Content-Type: text/plain; charset=utf-8
<
* Curl_http_done: called premature == 0
* Connection #0 to host localhost left intact
{"healthy":[{"actionable":true,"healthy":true,"name":"Sample Check","type":"SELF","dependent_on":{}}],"unhealthy":[]}

After

curl -v http://localhost:8077/healthcheck
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8077 (#0)
> GET /healthcheck HTTP/1.1
> Host: localhost:8077
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Fri, 17 Mar 2017 10:13:58 GMT
< Content-Length: 117
<
* Curl_http_done: called premature == 0
* Connection #0 to host localhost left intact
{"healthy":[{"actionable":true,"healthy":true,"name":"Sample Check","type":"SELF","dependent_on":{}}],"unhealthy":[]}

Since we return JSON, we should set `Content-Type=application/json`.

This messes up some monitoring we have, since it receives the default `Content-Type: text/plain; charset=utf-8` currently, and expects only JSON for its health checks.

Tested by building and running sample program before/after change.

h4. Before

```
curl -v http://localhost:8077/healthcheck
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8077 (#0)
> GET /healthcheck HTTP/1.1
> Host: localhost:8077
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 17 Mar 2017 10:05:54 GMT
< Content-Length: 117
< Content-Type: text/plain; charset=utf-8
<
* Curl_http_done: called premature == 0
* Connection #0 to host localhost left intact
{"healthy":[{"actionable":true,"healthy":true,"name":"Sample Check","type":"SELF","dependent_on":{}}],"unhealthy":[]}
```

h4. After

```
curl -v http://localhost:8077/healthcheck
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8077 (#0)
> GET /healthcheck HTTP/1.1
> Host: localhost:8077
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Fri, 17 Mar 2017 10:13:58 GMT
< Content-Length: 117
<
* Curl_http_done: called premature == 0
* Connection #0 to host localhost left intact
{"healthy":[{"actionable":true,"healthy":true,"name":"Sample Check","type":"SELF","dependent_on":{}}],"unhealthy":[]}
```
@alde
Copy link
Owner

alde commented Mar 17, 2017

Good catch :-)

👍

@alde alde merged commit 192d0fc into alde:master Mar 17, 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.

2 participants