GET works but telnet does not (HTTP GET)

0

I tried this from bash:

GET http://cetatenie.just.ro HTTP/1.1

It works fine, and I am able to get the page, then I try this from telnet:

telnet cetatenie.just.ro 80 
Trying 85.120.166.76...
Connected to cetatenie.just.ro.
Escape character is '^]'.
GET / HTTP/1.1
Host: cetatenie.just.ro

I get an Internal Server Error (Http Error Code 500)

The thing is, I do not really have access on the Server (it is an app deployed on IIS 7). Why does performing a GET work and accessing it through telnet does not?

All I could think of was that I need to send some additional headers. I tried using the Live Http Headers and sending the same thing that they do :

http://cetatenie.just.ro/

GET http://cetatenie.just.ro/ HTTP/1.1
Host: cetatenie.just.ro
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Proxy-Connection: keep-alive
Cookie: .ASPXANONYMOUS=Ij8RLazqzAEkAAAAMTk5ZjY0MGUtYWU0NC00ZmViLTgyNTgtMWU0MjNlM2IyZWEx0; language=en-US

But it still does not work with telnet.

Eugene

Posted 2011-12-12T08:42:39.573

Reputation: 103

GET is not a standard bash command. What is providing GET ? – Paul – 2011-12-12T08:51:45.157

1My bad, here it is : LWP-REQUEST. I did not even know I had this perl library :-) – Eugene – 2011-12-12T08:56:20.597

Answers

3

The server (Server: Microsoft-IIS/7.5) needs also a HOST-header as well as the USER-AGENT-header, I tried this:

 telnet cetatenie.just.ro 80 
 Trying 85.120.166.76...
 Connected to cetatenie.just.ro.
 Escape character is '^]'.
 GET / HTTP/1.1
 HOST: cetatenie.just.ro
 USER-AGENT: Foobar

and it worked.

math

Posted 2011-12-12T08:42:39.573

Reputation: 2 376

1I am sorry but are you sure? I have just tested what you did and still get an error response from the Server: <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1> – Eugene – 2011-12-12T09:30:31.710

1Can't answer my own-question :) for another 7 hours. Anyhow - @math you were almost right, I need the User-Agent header also. Thx – Eugene – 2011-12-12T09:34:55.790

Emm, sorry: I didn't saw that 500, in the server respond. And yes you are totally right, you need the user-agent header too. I will change my answer. – math – 2011-12-12T09:39:30.677

I will vote you up when I have enough points to :-) Cheers, Eugene – Eugene – 2011-12-12T09:49:59.073

@Eugene, you should be able to accept this as the correct answer by clicking on the tick under the number of votes. – Randy Orrison – 2011-12-12T10:02:55.190

aha, cool, thx! – Eugene – 2011-12-12T10:56:10.323

1

I tried it the way you describe and it also fails for me.

However, I managed to get it to work.

Add add user agent header. e.g. "User-Agent: wget/1.12"

You may also want to put Connection header.
i.e. "Connection: Keep-Alive" or "Connection: Close"

If you ever want to diagnose something like this, just load up a tool like wireshark. It's available for windows, linux and mac. This is when looking at why wget also worked. I guessed the user-agent field and then manually verified it with telnet. Sure enough - success!.

Matt H

Posted 2011-12-12T08:42:39.573

Reputation: 3 823