Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Tricat Lvl 2
Message 1 of 3

Blank response from Git.io 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 Git.io 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 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

 

2 Replies
Moderator
Message 2 of 3

Re: Blank response from Git.io urls

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.

Highlighted
Monocat Lvl 1
Message 3 of 3

Re: Blank response from Git.io urls

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

 

$ curl -Li https://git.io/vbAWM