Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
GET is not a standard bash command. What is providing GET ? –  Paul Dec 12 '11 at 8:51
1  
My bad, here it is : LWP-REQUEST. I did not even know I had this perl library :-) –  Eugene Dec 12 '11 at 8:56

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
1  
I 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 Dec 12 '11 at 9:30
1  
Can't answer my own-question :) for another 7 hours. Anyhow - @math you were almost right, I need the User-Agent header also. Thx –  Eugene Dec 12 '11 at 9:34
    
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 Dec 12 '11 at 9:39
    
I will vote you up when I have enough points to :-) Cheers, Eugene –  Eugene Dec 12 '11 at 9:49
    
@Eugene, you should be able to accept this as the correct answer by clicking on the tick under the number of votes. –  Randy Orrison Dec 12 '11 at 10:02

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!.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.