Forum Moderators: phranque

Message Too Old, No Replies

Using Telnet to 'simulate' a browser

looking at the raw HTML and headers

         

joshie76

10:43 am on Jan 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I had a peek at this thread [webmasterworld.com] and couldn't get it to work - I was having allsorts of bizarre problems :( here's exactly what I did, where am I going wrong?

- Opened the Run dialog and entered 'cmd' to bring up a command prompt.
- Entered 'telnet example.com 80'
- then the screen goes blank and I can't see what I'm typing
- I type 'HEAD / HTTP/1.0' anyway (though I can't see it) and hit enter twice
- I get 'HTTP/1.1 400 Bad Request' followed by some HTML for the bad request error page.

what's going on, why can't I see what I'm typing? I have to use telnet for this (long story), any help would be appreciated.

Dreamquick

11:51 am on Jan 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to enable local echo to see what you typed...

On 9X versions of telnet you can do this via the menu, on the w2k you need to enter telnet and type "set localecho".

Personally for all my non-scripted raw-requests I prefer NetCatNT (there is an NT version as well as a *nix version) as its a lot simplier, gives more information and is more suited for the task you are attempting - plus you can feed it stuff via the command line pipe.

Personally I never really use the HEAD request as 99% of the time I like to get the page content as well as the headers. Typically with HTTP 1.0 you can get away with;

GET / HTTP/1.0

However if you want to try using the HTTP 1.1 protocol you need to add a little more - otherwise you can end up getting 400 errors and other such fun

GET / HTTP/1.1
Host: www.example.com
Connection: Close

Potentially one reason for you getting 400 errors is that you are trying to query a site which is on a virtual host without supplying a HOST: header, in effect not telling the virtual host which site you are interested in...

- Tony

joshie76

12:26 pm on Jan 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for your help Tony but I'm still not having no luck here.

when do I type 'set localecho'?

whenever I do it I get the 400 Bad Request error?

What on earth am I doing wrong?


GET / HTTP/1.1
Host: www.example.com
Connection: Close

How do I type in three lines without 'firing' the first one when I press enter?

Dreamquick

12:57 pm on Jan 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Multiple lines
Using telnet there is no way to send multi-line data directly as every keypress gets sent to the server instantly.

To be honest you find this problem with a lot of raw request tools - they either send data with every keystroke or when you press return. Often the way around this is to copy and paste multi-line data into the window...

However that said HTTP requests do allow multi-line input, ie

GET / HTTP/1.1<rtn>
HOST: example.com<rtn>
CONNECTION: Close<rtn>
<rtn>
<rtn>

With the double return terminating the input portion of the request and telling the server to process what it has been given so far...

Where do you type set localecho?
1) Start telnet but don't use any parameters to force it to enter the command line mode.

2) At the "Microsoft Telnet>" prompt type in "set localecho"

3) It responds "Local echo on", and you should now be able see what you are typing.

- Tony

joshie76

2:08 pm on Jan 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you - working a treat.

Don't suppose there is anyway of stopping the cursor going up to the top left and overwriting everything - makes it very hard to see what you're doing?

[edited by: joshie76 at 3:07 pm (utc) on Jan. 7, 2003]

andreasfriedrich

2:21 pm on Jan 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are running Windows using cygwin´s version of telnet is quite helpful.

Andreas