Search code examples
telnetapache

black screen and error 400 bad request


I was trying telnet into a Web server and send a multiline request message. I have to include in the request message the If-modified-since. I made settings for Win7.

For instance when I type telnet edition.cnn.com 80 on my command prompt, it opens a black empty screen, I don't see any thing that I type.

Then I wrote this line on the black screen GET pageName HTTP/1.0, it returned 400 Bad Request Error and says connection closed. What should I do? I used get pagename for an example.


Solution

  • If you want to use e.g. a telnet client to manually get web-pages, you have to remember the format of a HTTP request header:

    GET pageName HTTP/1.0
    additional header
    additional header
    
    

    Note that the last line is an empty line. You might also need HTTP/1.1 for certain headers to make sense. Please read a HTTP specification for more information and what headers are standard.


    The "black screen" is simply the telnet program running in a command window.