Telnet - Google Drive GET request error

1

I'm on Mac OSX trying to use telnet to get a file off of google drive. I found that the following link template causes an automatic download of a file off of google drive:

http://drive.google.com/uc?id=documentId&export=download

where documentId is the id of the document (a combination of numbers and letters). So I go to the terminal, type telnet drive.google.com 80 and get connected to the server. Then I type GET /uc?id=documentId&export=download HTTP/1.1, press enter, type Host: drive.google.com, then press enter twice.

I'm pretty sure I followed the steps correctly, but for some reason, I always get a status code of 302 Moved Temporarily. Did I enter the URL wrong, are there some characters that need to be escaped? Any suggestions would be helpful.

rcplusplus

Posted 2012-07-23T21:04:21.200

Reputation: 113

Answers

1

302 Moved Temporarily is not an error of any kind. It's the HTTP server telling you that the URL is okay but the actual content is at a different location; for example, it might be redirecting you to one of Google's storage servers, or asking to try again over HTTPS.

Look for a Location: header in the response and issue a second HTTP request for it (after connecting to the apropriate server if needed).

As a better alternative, try curl -L -o <filename> <url>.
(Add -v if you want to see the HTTP requests in action.)

user1686

Posted 2012-07-23T21:04:21.200

Reputation: 283 655

is curl an actual command? Because I'm just using telnet to test out the HTTP request which later I'm going to use in a C++ program to download the file off the internet. – rcplusplus – 2012-07-24T03:39:40.733

And also, the "new location" link it gives me is this: /uc?id=documentId&amp;export=download, which is the exact same thing [!] as the provided link save for the ampersand being replaced by &amp – rcplusplus – 2012-07-24T03:43:02.570

@rcplusplus: If it has something different, then it's not exactly the same thing, is it? – user1686 – 2012-07-24T11:20:51.587

@rcplusplus: And yes, curl is an actual command, but it also comes with a libcurl library for C which is very convenient for downloading files over HTTP, among other things. – user1686 – 2012-07-24T11:21:22.173

0

Need to use HTTPS, do you have some kind of SSL-equipped telnet?

Ali Afshar

Posted 2012-07-23T21:04:21.200

Reputation: 101

Tried it your way with openssl, and it worked! Well, it gave me HTML saying "Moved Temporarily" and then had a <a></a> element directing me to the file. All I do is click it and then the file downloads. And that URL is the Location: parameter in the response header – rcplusplus – 2012-07-24T04:53:35.883