In an earlier post, I talked about HTTP and how to use the TELNET client to manually perform HTTP requests independent of a browser. TELNET works great when playing around with requests on your local PC, but gets finicky when trying to connect to remote servers. Plus, it's just plain tedious to work with.
I found that a better alternative is to write a little program to make these requests and then output the response to a text file. It's actually pretty simple to do this in .NET by using the WebRequest class. Here is a link to where you can find everything you need to know about WebRequest.
Showing posts with label Telnet. Show all posts
Showing posts with label Telnet. Show all posts
Tuesday, July 21, 2015
Tuesday, November 12, 2013
HTTP, Fiddler, and Telnet
HTTP is the "language" that browsers (clients) use to communicate with web servers. Browsers send "request" messages to the web server. The web server sends back "response" messages to the browser. Each message consists of:
The intial line of a request contains the "verb". HTTP consists of only a handful of verbs that tell the web server what kind of request they are making. GET is the most popular request made by a browser. The browser is requesting a particular resource (html, image, other file, etc.) which is specified in the initial line of the message by indicating its URL.
The intial line of a response contains a status code and a very short description. For example, "HTTP/1.1 200 OK". The body of a response contains the actual resource. For example, it would contain the html if that is what was requested.
You can actually see these messages going back and forth with a little program called Fiddler. Just download Fiddler, install it, and run it. If you type in a URL in a browser, you will see the corresponding GET request message in Fiddler. Click on the Inspectors tab to see the initial line and "headers".
If you want to see the response messages, you have to download an add on called Syntax Highlighting AddOns. There should be a link below the box that displays the details of the request message. Once you install this, add on, you can see the details of the response for each request. Pretty cool.
Going a step further, you can make GET requests manually independent of a browser by using Telnet. By default, in Windows 7, Telnet is not enabled. You have to go into Control Panel and Add/Remove Windows Features. Enable the Telnet Client. Then, just open up a command prompt and type as an example:
Telnet localhost 3405
-Ctrl ]-
set localecho
-Enter-
-Enter again-
GET /test.html HTTP/1.1
Host: localhost
-Enter-
-Enter again-
Now you see the response message from the web server.
Pretty cool.
Here's a good link to some helpful (if a bit dated) info on HTTP:
http://www.jmarshall.com/easy/http/
- An initial line that summarizes the message.
- A "headers" section that contains helpful information about the message.
- The body of the message.
The intial line of a request contains the "verb". HTTP consists of only a handful of verbs that tell the web server what kind of request they are making. GET is the most popular request made by a browser. The browser is requesting a particular resource (html, image, other file, etc.) which is specified in the initial line of the message by indicating its URL.
The intial line of a response contains a status code and a very short description. For example, "HTTP/1.1 200 OK". The body of a response contains the actual resource. For example, it would contain the html if that is what was requested.
You can actually see these messages going back and forth with a little program called Fiddler. Just download Fiddler, install it, and run it. If you type in a URL in a browser, you will see the corresponding GET request message in Fiddler. Click on the Inspectors tab to see the initial line and "headers".
If you want to see the response messages, you have to download an add on called Syntax Highlighting AddOns. There should be a link below the box that displays the details of the request message. Once you install this, add on, you can see the details of the response for each request. Pretty cool.
Going a step further, you can make GET requests manually independent of a browser by using Telnet. By default, in Windows 7, Telnet is not enabled. You have to go into Control Panel and Add/Remove Windows Features. Enable the Telnet Client. Then, just open up a command prompt and type as an example:
Telnet localhost 3405
-Ctrl ]-
set localecho
-Enter-
-Enter again-
GET /test.html HTTP/1.1
Host: localhost
-Enter-
-Enter again-
Now you see the response message from the web server.
Pretty cool.
Here's a good link to some helpful (if a bit dated) info on HTTP:
http://www.jmarshall.com/easy/http/
Subscribe to:
Posts (Atom)