title: Rest API response headers for json data?
body: <p>This is likely a duplicate but I wasn't able to word my query in a way that yielded a situation like mine. Thanks for any help answering or refining the question.</p>
  
  <p>I've implemented a simple REST api in java / apache camel. When I invoke an endpoint with a <code>GET</code> request from my <em><strong>browser</strong></em>, I get the response I expect:</p>
  
  <h2>From my browser:</h2>
  
  <p><code>GET http://localhost:8080/app/pipeline?text=hello</code>
  <code>
  {"input":"hello"}
  </code></p>
  
  <h3>Request Headers:</h3>
  
  <pre><code>Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
  Accept-Encoding:gzip, deflate, sdch, br
  Accept-Language:en-US,en;q=0.8
  Cache-Control:no-cache
  Connection:keep-alive
  Host:localhost:8080
  Pragma:no-cache
  Upgrade-Insecure-Requests:1
  User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
  </code></pre>
  
  <h3>Response Headers:</h3>
  
  <pre><code>Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
  Accept-Encoding:gzip, deflate, sdch, br
  Accept-Language:en-US,en;q=0.8
  Access-Control-Allow-Headers:Origin, Accept, X-Requested-With, Content-Type, 
  Access-Control-Request-Method, Access-Control-Request-Headers
  Access-Control-Allow-Methods:GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH
  Access-Control-Allow-Origin:*
  Access-Control-Max-Age:3600
  Connection:keep-alive
  Content-Length:31
  Content-Type:application/json
  Upgrade-Insecure-Requests:1
  User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
  </code></pre>
  
  <h2>From Curl:</h2>
  
  <p>Now the problem comes in when I hit the same endpoint via curl:</p>
  
  <pre><code>$ curl -i 'http://localhost:8080/app/pipeline?text=hi' 
  HTTP/1.1 200 OK
  Content-Length: 42
  Accept: */*
  Access-Control-Allow-Headers: Origin, Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers
  Access-Control-Allow-Methods:
  GET,HEAD,POST,PUT,DELETE,TRACE,OPTIONS,CONNECT,PATCH
  Access-Control-Allow-Origin: *
  Access-Control-Max-Age: 3600
  text: hi
  User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
  Content-Type: application/json
  Connection: keep-alive
  
  "eyJpbnB1dCI6ImhpIiwibWV0YWRhdGEiOnt9fQ=="
  </code></pre>
  
  <p>I get this weird encoded response above. I'm learning about the Accept and Encoding type headers, so I set the accept and content-encoding header like my request from chrome had:</p>
  
  <pre><code>$ curl -i -sH 'Accept: application/json' -sH 'Content-Encoding: gzip, deflate, sdch, br' 'http://localhost:8080/app/pipeline?text=hi' 
  HTTP/1.1 200 OK
  Content-Length: 42
  Accept: application/json
  Access-Control-Allow-Headers: Origin, Accept, X-Requested-With, Content-Type,     Access-Control-Request-Method, Access-Control-Request-Headers
  Access-Control-Allow-Methods: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH
  Access-Control-Allow-Origin: *
  Access-Control-Max-Age: 3600
  Content-Encoding: gzip, deflate, sdch, br
  text: hi
  User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
  Content-Type: application/json
  Connection: keep-alive
  
  "eyJpbnB1dCI6ImhpIiwibWV0YWRhdGEiOnt9fQ=="
  </code></pre>
  
  <p>What the heck? It turns out that unless I specify the Accept header exactly how it was in the chrome request, I get this weird output. With that header set I get the desired response:</p>
  
  <pre><code>$ curl -i -sH 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -sH 'Content-Encoding: gzip, deflate, sdch, br' 'http://localhost:8080/app/pipeline?text=hi' 
  HTTP/1.1 200 OK
  Content-Length: 28
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
  Access-Control-Allow-Headers: Origin, Accept, X-Requested-With, Content-Type,     Access-Control-Request-Method, Access-Control-Request-Headers
  Access-Control-Allow-Methods: GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH
  Access-Control-Allow-Origin: *
  Access-Control-Max-Age: 3600
  Content-Encoding: gzip, deflate, sdch, br
  text: hi
  User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
  Content-Type: application/json
  Connection: keep-alive
  
  {"input":"hi","metadata":{}}
  </code></pre>
  
  <h1>The Question</h1>
  
  <p>I'm returning application/json from my service, so why does my request not work unless I specify the header like this: <code>Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8</code> ? I assume <code>*/*</code> includes everything, but it doesn't work if I <strong>just</strong> supply <code>*/*</code> in the header, or if I <strong>just</strong> supply application/json. </p>
  
  <p>Any leads in the right direction to understanding are much appreciated.</p>