Blank response from urls

Hi all,

I have a simple program called Upshot which creates a secret Gist from a local .json file. A shortened version of the raw_url is returned using the service.

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

This curl request shows the result, however a different Content-Type header is set.

curl -i

The 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
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 :grinning: 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.

Redirects can be followed with cURL by passing the -L option.

$ curl -Li