What is HTTP?
What is HTTP?
HTTP is the protocol that web clients (like a browser) and a server use to talk to one another.
Knowledge of HTTP is essential for understanding how web performance test scripts or in general web work. When we are looking at performance logs, knowledge of HTTP understanding will help us to verify that a HTTP request was successful and that there were no errors generated during a test run.
All HTTP messages are generally made up of three main parts:
- Request– a client makes a request using either a GET or a POST method
· GET method – is a request for info located at a specified location on the server. “GET” is basically for just getting (retrieving) data.
· POST method – allows data to be sent to the server within a client’s request (an html form would be one example). “POST” may involve anything, like storing or updating data, or ordering a product, or sending E-mail.
- Headers - zero or more header lines that can contain information, like Browser, OS, Accept and Cookie info.
- Body - An optional message body.
When you record an HTTP script using Web (HTTP/HTML) protocol in LoadRunner, the tool captures all of the communication between the browser and the Web server. The captured info becomes part of the script, which is then played back. When you run the script it interacts with the web application -- just like a real user.
Let's look at an Example of a HTTP Request and Response
When making a request from a browser, you don’t often see the HTTP being passed back and forth along with the headers; however, looking at this info is easy in LoadRunner. Record a script and verify the below in Generation Log tab of LoadRunner.
Let's take a look at what an actual request and response looks like:
The Requests to URL http://www.yahoo.com/
****** Request Header For Transaction With Id 249 ******
GET http://in.yahoo.com/?p=us HTTP/1.1
Accept: */*
Accept-Language: en-us
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; .NET4.0C; .NET4.0E; InfoPath.3)
Accept-Encoding: gzip, deflate
Proxy-Connection: Keep-Alive
Cookie: -------
Host: in.yahoo.com
$$$$$$ Request Header For Transaction With Id 249 Ended $$$$$$
- Looking at the above, we can see that the first line in the request uses the GET method to request the document in.yahoo.com using HTTP version 1.1
- Next, the client sends header information, such as the browser version, to tell the servers its configuration and the type of docs it will accept.
- The client then sends a blank line to end the header.
****** Response Header For Transaction With Id 249 ******
HTTP/1.0 200 OK
Date: Wed, 06 Jun 2012 06:30:21 GMT
P3P: policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
Cache-Control: private
X-Frame-Options: SAMEORIGIN
Set-Cookie: XXXX
Vary: Accept-Encoding
Content-Type: text/html;charset=utf-8
Age: 0
Server: YTS/1.20.10
X-Cache: MISS from iproxy6n
X-Cache: MISS from myproxy
Via: 1.0 iproxy6n:8080 (squid/2.7.STABLE2), 1.0 myproxy (squid/3.1.10)
Connection: close
$$$$$$ Response Header For Transaction With Id 249 Ended $$$$$$
The first line of the response contains the HTTP version and status code along with the status description. Status 200 means OK, means that our client’s request was successful.
- Next, the server sends its header info to the client along with the requested doc.
- A blank line ends the header.
- Since the client’s request was successful, the requested data is sent.
Our example returns the status code 200, so we know everything is okay with the request. However, there are many other things that could have gone wrong. Here are the HTTP status codes and their descriptions:
Status | Description |
200 OK - The request succeeded
201 Created - The request was fulfilled and a new URI was created
202 Accepted – Request accepted but not immediately acted upon
203 Non-authoritative Information – info in the entity header is from a local or third-party copy and not found on original server
204 No Content- requests received but no info to send back
Response's in the range of 300-399 mean that the request was not performed – further action needed
300 Redirection
301 Moved - The data requested has a new location and the change is permanent
302 Found - The data requested has a different URL temporarily
303 Method - Under discussion, a suggestion for the client to try another location
304 Not Modified - The document has not been modified as expected
Response's in the range of 400-499 mean that the request was incomplete and may need more info
400 Bad Request - Syntax error in the request or it could not be satisfied
401 Unauthorized - The client is not authorized to access data
402 Payment Required - indicates a charging scheme is in effect
403 Forbidden - Access not required even with authorization
404 Not Found - Server could not find the given resource
Response's in the range of 500-599 mean that the server encountered an error
500 Internal Error - The server could not fulfill the request because of an unexpected condition
501 Not Implemented - The server does not support the facility requested
502 Server Overloaded - High load or servicing – in progress
503 Gateway Timeout - Server waited for another service that did not complete in time.
Thank you for sharing your thoughts and knowledge on this topic. This is really helpful and informative, as this gave me more insight to create more ideas and solutions for my plan. I would love to see more updates from you.
ReplyDeleteWeb Development