Monday, June 23, 2014

Part 1 Http Unrevealed

Part 1 Hypertext Transfer Protocol
Whatever we see in www is possible through http protocol.

Few know-how to be familiar with HTTP.

Resource Locators: URL Uniform Resource locator.

URL path
://:/?#
http://somthing.com - host name
http://somthing.com/author/santosh


URL with keyword such as author is help rank your website for given search keywords in URL.It improves your Search Engine Optimization.

By default URL with out port points to port 80. Other than port 80, one needs to mention or host url with port number.

#sign represents fragment. The fragment locate a specific HTML element in a html page by control ids. For example bookmark in given page.

URL EncodingUnsafe characters such space and ^ carat are replaced with %
%20 is the encoding for a space character ( 20 is hexadecimal value = US-ASCII space character).
%5 represents ^

Resources and Media

Web page can request different resource format for display for end users they can be executable applications ,mages, XML , Json,video,HTML audio etc.
When a host server responds to an HTTP request, it returns a resource and also specifies the content type. This content type is called Media type. Media type is represented by Multipurpose Internet Mail Extensions (MIME) standards.
Client request content type html then it will send text/html
Similarly
"image/jpeg"
"image/gif"
"image/png"

File Extension in URL

File extensions not always output requested file extension as given example http://something.com/main.jpg
How it works:-
1. Client first look at response header content type tag send by host server.
2. If content type not available it will parse first 200 bytes of response to identify content type.
3. If client fails to identify content type and first 200 bytes of response then it look into URL file extension to guess content type.

Content Type Negotiation

Client can tell host server what content type it want at time of response. For example some resource of book url may suggest the client may display book content in some specific language and can be downloaded in specific format.In such scenarioncontent type negotiation plays a essential role.
Accept keyword in Response header suggests this.

Accept-Language: fr-FR

Http Request Method
Method Description
GET Safe Method:Retrieve a resource
PUT Store a resource
DELETE Remove a resource
POST Update a resource
HEAD Retrieve the headers for a resource

HTTP Response Request

A full HTTP request might look like the following.
Request
GET http://something.com/ HTTP/1.1
Host: something.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) Chrome/16.0.912.75 Safari/535.7
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://www.google.com/url?&q=odetocode
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

Response

HTTP/1.1 200 OK

Cache-Control: private

Content-Type: text/html; charset=utf-8

Server: Microsoft-IIS/7.0

X-AspNet-Version: 2.0.50727

X-Powered-By: ASP.NET

Date: Sat, 14 Jan 2012 04:00:08 GMT

Connection: close

Content-Length: 17151

Http Status Code Classification
Range Category
100–199 Informational
200–299 Successful
300–399 Redirection
400–499 Client Error
500–599 Server Error

With the help of  Fiddler Tool we can read and analyze the http response and request.

No comments :