1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

How HTTP Works?

Discussion in 'Web Development' started by lionaneesh, Jan 30, 2011.

  1. lionaneesh

    lionaneesh New Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    India
    HTTP is an abbreviated form of Hyper Text Transfer Protocol..As we all know HTTP set the foundations for internet and WWW [world wide web]...I'll not go in much detail of its history, but I'll get straight to the topic of

    How HTTP works



    HTTP is a request response protocol to communicate asynchrnously between client and server. Mostly in HTTP a browser acts as a client and a web-server like Apache or IIS acts as server. The server which hosts the files (like html , audio , video files etc) responses to the client. Depending on the request a response contains the status of the request.

    What a Request Message contains?

    A request can be a line such as :-

    Code:
    GET /index.php HTTP/1.1
    Which request the file /index.php from the server …

    Headers can be like
    Code:
    Accept-Language: en
    Note : Every line of HTTP request should end with <cr> <lf> [carriage return and line feed]. And the empty line should contain only <cr><lf> no other data, not even white space.

    In HTTP/1.1 all headers are optional except the Host...

    Different types of HTTP requests



    There are 9 types of HTTP requests/method.

    GET
    This request is Used to get the Response header and the response body!!​
    eg :-
    Code:
    aneesh@aneesh-laptop:~$ telnet www.go4expert.com 80 
    Trying 174.133.80.67... 
    Connected to www.go4expert.com. 
    Escape character is '^]'. 
    GET / HTTP/1.1 
    Host : www.go4expert.com 
     
    HTTP/1.1 200 OK 
    Date: Sun, 30 Jan 2011 08:03:36 GMT 
    Server: Apache 
    X-Powered-By: PHP/5.2.10 
    Set-Cookie: expertlastvisit=1296374633; expires=Mon, 30-Jan-2012 08:03:53 GMT; path=/ 
    Set-Cookie: expertlastactivity=0; expires=Mon, 30-Jan-2012 08:03:53 GMT; path=/ 
    Cache-Control: private 
    Pragma: private 
    X-UA-Compatible: IE=7 
    Set-Cookie: vbseo_loggedin=deleted; expires=Sat, 30-Jan-2010 08:03:52 GMT; path=/ 
    Vary: Accept-Encoding,User-Agent 
    Transfer-Encoding: chunked 
    Content-Type: text/html; charset=ISO-8859-1 
    
    14aec 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html dir="ltr" lang="en" xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    
    	<meta http-equiv="Cache-Control" content="no-cache" /> 
    	<meta http-equiv="Pragma" content="no-cache" /> 
    	<meta http-equiv="Expires" content="0" /> 
    <title>Programming and SEO Forums </title>
    
    Output truncated to save space 
    
    HEAD
    This request is used to get back The response header only (not the response body as returned by the GET request..)
    eg :-

    Code:
    aneesh@aneesh-laptop:~$ telnet www.go4expert.com 80 
    Trying 174.133.80.67... 
    Connected to www.go4expert.com. 
    Escape character is '^]'. 
    HEAD / HTTP/1.1 
    Host : www.go4expert.com 
    
    HTTP/1.1 200 OK 
    Date: Sun, 30 Jan 2011 08:12:47 GMT 
    Server: Apache 
    X-Powered-By: PHP/5.2.10 
    Set-Cookie: expertlastvisit=1296375177; expires=Mon, 30-Jan-2012 08:12:57 GMT; path=/ 
    Set-Cookie: expertlastactivity=0; expires=Mon, 30-Jan-2012 08:12:57 GMT; path=/ 
    Cache-Control: private 
    Pragma: private 
    X-UA-Compatible: IE=7 
    Set-Cookie: vbseo_loggedin=deleted; expires=Sat, 30-Jan-2010 08:12:56 GMT; path=/ 
    Vary: Accept-Encoding,User-Agent 
    Content-Type: text/html; charset=ISO-8859-1 
    
    Connection closed by foreign host. 
    aneesh@aneesh-laptop:~$ 
    
    POST
    This request is used to submit data (eg : for to be used in HTML forms etc..)...
    PUT
    Used for uploading resource
    PATCH
    Is used to modify the resource​
    DELETE
    Used for deleting resource​
    TRACE
    simply echoes back the request sent by the client...
    This can be used for testing the servers and Checking weather the server is alive or not..​

    Code:
    aneesh@aneesh-laptop:~$ telnet www.go4expert.com 80 
    Trying 174.133.80.67... 
    Connected to www.go4expert.com. 
    Escape character is '^]'. 
    TRACE / HTTP/1.1 
    Host : www.go4expert.com 
    
    HTTP/1.1 200 OK 
    Date: Sun, 30 Jan 2011 08:16:05 GMT 
    Server: Apache 
    Transfer-Encoding: chunked 
    Content-Type: message/http 
    
    2d 
    TRACE / HTTP/1.1 
    Host: www.go4expert.com 
    
    
    0 
    
    Connection closed by foreign host. 
    
    CONNECT
    Convert the It transparent TCP/IP tunnel , usually to facilitate SSL encrypted Communicated (HTTPS) through an unencrypted HTTP proxy.. This is usually used in the login / signup pages in which the data needs to be encrypted so as to protect it from sniffers etc etc...​
    OPTIONS

    This request returns back the HTTP options/methods supported by the server...​

    Summary



    Client side :-

    Basically as A http client sends a HTTP request. The client actually establishes a TCP connection to the port no on the host... (Mostly its 80 but can be change according to the setting of the server..)

    Then the host send back the requested resource with a status code...
    Like 202 , 404 (refer http://en.wikipedia.org/wiki/List_of_HTTP_status_codes to know more about the status codes)

    A basic client request :-

    Code:
    GET / HTTP/1.1 
    Host : www.go4expert.com 
    
    Server side :-

    A HTTP web server listens for requests on the port no specified (default : 80)...As the Server gets a request it returns back the requested resource with a status code...

    A basic server output :-

    I will try to explain each of them with an example using my Own HTTP Server.

    Code:
    aneesh@aneesh-laptop:~$ sudo '~/Programming/C/Ani-srver/web_server' 
    [sudo] password for aneesh: 
    Server is open for listening on port 80 
    Got connection from 0.0.0.0 
    Got connection from :: 
    
    
    Request by browser = GET / HTTP/1.1 
    
    
    REq=/index.html 
    Opening "/home/aneesh/aniroot/index.html" 
    200 OK!!! 
    Got connection from 0.0.0.0 
    Got connection from :: 
    
    
    Request by browser = GET /favicon.ico HTTP/1.1 
    
    
    REq=/favicon.ico 
    Opening "/home/aneesh/aniroot/favicon.ico" 
    404 File not found Error 
    Got connection from 0.0.0.0 
    Got connection from :: 
    
    
    Request by browser = GET /favicon.ico HTTP/1.1 
    
    
    REq=/favicon.ico 
    Opening "/home/aneesh/aniroot/favicon.ico" 
    404 File not found Error 
    
     
    shabbir likes this.
  2. lionaneesh

    lionaneesh New Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    India
    I hope you liked it...
    Please comment!!!!
     
  3. seangtz

    seangtz New Member

    Joined:
    Jun 6, 2008
    Messages:
    126
    Likes Received:
    3
    Trophy Points:
    0
    Useful information, It will be great help if you share what http we are using in seo ?
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    HTTP for SEO??
     
  5. lionaneesh

    lionaneesh New Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    India
    Cant understand your request buddy...
    Can you please clear it!!!
     
  6. shrikrishnatech

    shrikrishnatech New Member

    Joined:
    Nov 19, 2010
    Messages:
    42
    Likes Received:
    4
    Trophy Points:
    0
    Occupation:
    Wordpress theme, Wordpress Theming, WP Themes, Cor
    Home Page:
    above which you are explained for HTML it is validate for XHTML & DHTML ?
     
  7. lionaneesh

    lionaneesh New Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    India
    These are just another forms of HTML and I have explained for HTTP..

    Basically , XHTML is a combination of XML and HTML..
    2. DHTML is Dynamic HTML ... This is because of use of various languages..like PHP , JavaScript..etc...etc...

    There is not much differenced in these...

    Basically , Every page on the Web Follows HTTP Rules and HTML Markup!!
     
  8. shrikrishnatech

    shrikrishnatech New Member

    Joined:
    Nov 19, 2010
    Messages:
    42
    Likes Received:
    4
    Trophy Points:
    0
    Occupation:
    Wordpress theme, Wordpress Theming, WP Themes, Cor
    Home Page:
    ohhh thanks i have little confusion on that thanks for resolve it
     
  9. lionaneesh

    lionaneesh New Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    India
    My pleasure...
     
  10. dhirendra.gvt

    dhirendra.gvt Banned

    Joined:
    Nov 22, 2010
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    SEO
    Location:
    Delhi
    Home Page:
    Hi Guys,

    Hypertext transfer protocol provides a way for clients such as web browsers to communicate with web servers. There's quite a bit on the web that's written on the topic, so for the time being we'll just provide some good links for you.
     
  11. jacktom

    jacktom New Member

    Joined:
    Apr 4, 2011
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    Great think i came to know
     
  12. juliaandrews

    juliaandrews New Member

    Joined:
    May 12, 2011
    Messages:
    25
    Likes Received:
    0
    Trophy Points:
    0
    Hello,
    HTTP stands for Hypertext transfer protocol.Basically as A http client sends a HTTP request and client actually established a TCP connection to the host.
    Thanks
     
  13. Eldridge13

    Eldridge13 New Member

    Joined:
    May 23, 2011
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    USA
    Home Page:
    I have a lot of confusion when I read this post.
     
  14. lionaneesh

    lionaneesh New Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    India
    Thanks!

    Please Share your confusion so that i could help solving it! :D:D
     
  15. Lulugreen

    Lulugreen New Member

    Joined:
    May 23, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    i like to visit the go4expert forums because I can get some important information that I need. This content of this article is searched for by me. Thanks!
     
  16. amrithaa2011

    amrithaa2011 Banned

    Joined:
    May 23, 2011
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    hi,

    HTTP works depend upon the server processing & Browser coding...!!! meet again.
     
  17. jhon786

    jhon786 New Member

    Joined:
    Oct 12, 2011
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    0
    Thanks for explaining this information about HTTP. Nice.
     
  18. lionaneesh

    lionaneesh New Member

    Joined:
    Mar 21, 2010
    Messages:
    848
    Likes Received:
    224
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    India
    My Pleasure :pleased:
     
  19. Sajjadahmadbwp

    Sajjadahmadbwp New Member

    Joined:
    Feb 29, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    It is very informative data for internet users.
     
  20. styris

    styris Banned

    Joined:
    Nov 29, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    On reading your post i got an clear idea about how http works. Good work
     

Share This Page