The aforementioned program has been working great until recently when I have discovered that the Content-Type header is being set to text/html for JSON data. As such, cURL requests are returning blank results.
Is anybody else aware of this issue? The following requests demonstrate the problem.
This curl request shows the incorrect Content-Type heading.
curl -i https://git.io/vbAWM
This curl request shows the result, however a different Content-Type header is set.
curl -i https://gist.githubusercontent.com/anonymous/fa0aa63cba66417e2ccbfd75dff29173/raw/5e5d6d3b2d467a8084e6c253c37b3745bf2380cb/test.json
The git.io service is returning the following content:
HTTP/1.1 302 Found Server: Cowboy Connection: keep-alive Date: Tue, 02 Jan 2018 18:18:56 GMT Status: 302 Found Content-Type: text/html;charset=utf-8 Location: https://gist.githubusercontent.com/anonymous/fa0aa63cba66417e2ccbfd75dff29173/raw/5e5d6d3b2d467a8084e6c253c37b3745bf2380cb/test.json Content-Length: 0 X-Xss-Protection: 1; mode=block X-Content-Type-Options: nosniff X-Frame-Options: SAMEORIGIN X-Runtime: 0.009227 X-Node: 97030659-061f-401f-bd89-27e4d412e387 X-Revision: 392798d237fc1aa5cd55cada10d2945773e741a8 Strict-Transport-Security: max-age=31536000; includeSubDomains Via: 1.1 vegur
Note that the HTTP status code is 302 Found, in other words a redirect to the location listed in the Location header. It's not returning no results because of the content type ... it's returning no results because it is trying to redirect you to the actual URL. That's what URL shorteners do 😀 They give you a shorter URL and redirect you to the real thing. So if you want to use the shorter URL, you have to follow the redirect to the ultimate destination to get the data.