Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

KMUTNB - Internet Programming 2/7


Published on

Lecture for King Mongkut's University of Technology North Bangkok (KMUTNB) / Computer Science / Internet Programming Course by PHUPHA

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

KMUTNB - Internet Programming 2/7

  1. 1. Web application Architecture and HTTP Protocol By: Mr. PHUPHA PUNYAPOTASAKUL ( ภูผา ปัญญาโพธาสกุล )
  2. 2. World Wide Web HTML HTTP TCP/IP Network Layer
  3. 3. HTTP Protocol <ul><li>Hypertext Transfer Protocol ( HTTP ) is a communications protocol used to transfer or convey information on intranets and the World Wide Web . Its original purpose was to provide a way to publish and retrieve hypertext pages. Development of HTTP was coordinated by the W3C ( World Wide Web Consortium ) and the IETF ( Internet Engineering Task Force ), culminating in the publication of a series of RFCs , most notably RFC 2616 ( June 1999 ), which defines HTTP/1.1, the version of HTTP in common use. </li></ul>
  4. 4. HTTP Specification <ul><li>HTTP 1.1 </li></ul><ul><li>HTTP 1.0 </li></ul>
  5. 5. HTTP Request/Response Server Browser HTTP Response HTTP Request
  6. 6. HTTP Request Methods <ul><li>HEAD </li></ul><ul><ul><li>Asks for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content. </li></ul></ul><ul><li>GET </li></ul><ul><ul><li>Requests a representation of the specified resource. By far the most common method used on the Web today. Should not be used for operations that cause side-effects (using it for actions in web applications is a common misuse). See 'safe methods' below. </li></ul></ul><ul><li>POST </li></ul><ul><ul><li>Submits data to be processed (e.g. from an HTML form ) to the identified resource. The data is included in the body of the request. This may result in the creation of a new resource or the updates of existing resources or both. </li></ul></ul>
  7. 7. HTTP Request Methods <ul><li>PUT </li></ul><ul><ul><li>Uploads a representation of the specified resource. </li></ul></ul><ul><li>DELETE </li></ul><ul><ul><li>Deletes the specified resource. </li></ul></ul><ul><li>TRACE </li></ul><ul><ul><li>Echoes back the received request, so that a client can see what intermediate servers are adding or changing in the request. </li></ul></ul><ul><li>OPTIONS </li></ul><ul><ul><li>Returns the HTTP methods that the server supports. This can be used to check the functionality of a web server. </li></ul></ul><ul><li>CONNECT </li></ul><ul><ul><li>Converts the request connection to a transparent TCP / IP tunnel , usually to facilitate SSL -encrypted communication (HTTPS) through an unencrypted HTTP proxy . [ 1 ] </li></ul></ul>
  8. 8. HTTP Example <ul><li>HTTP Request </li></ul><ul><li>GET /index.html HTTP/1.1 </li></ul><ul><li>Host: </li></ul><ul><li>HTTP Response </li></ul><ul><li>HTTP / 1.1 200 OK </li></ul><ul><li>Date : Mon, 23 May 2005 22:38:34 GMT </li></ul><ul><li>Server : Apache / 1.3.27 ( Unix ) ( Red - Hat / Linux ) </li></ul><ul><li>Last - Modified : Wed, 08 Jan 2003 23:11:55 GMT </li></ul><ul><li>Accept - Ranges : bytes </li></ul><ul><li>Content - Length : 438 </li></ul><ul><li>Connection : close </li></ul><ul><li>Content - Type : text / html; charset = UTF-8 </li></ul><ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><TITLE>Title</TITLE> </li></ul><ul><li>… . </li></ul>
  9. 9. HTML
  10. 10. HTML Example <ul><li><html> </li></ul><ul><li><head> </li></ul><ul><li><title>Title< / title> </li></ul><ul><li><meta http - equiv =&quot; Content - Type &quot; content =&quot; text / html; charset = utf-8 &quot; > </li></ul><ul><li><link href =&quot;../ style / framework . css &quot; rel =&quot; stylesheet &quot; type =&quot; text / css &quot; > </li></ul><ul><li><script language =&quot; JavaScript &quot; src =&quot;../ script / framework / config . js &quot; >< / script> </li></ul><ul><li>< / head> </li></ul><ul><li><body leftmargin =&quot; 0 &quot; topmargin =&quot; 0 &quot; marginwidth =&quot; 0 &quot; marginheight =&quot; 0 &quot; > </li></ul><ul><li>… . </li></ul><ul><li>… .. </li></ul><ul><li>… . </li></ul><ul><li></body> </li></ul><ul><li></html> </li></ul>
  11. 11. HTML Specification <ul><li>Reference http :// www . w3 . org / TR / html4 / </li></ul><ul><li>Maintain by </li></ul><ul><li>Support History http:// </li></ul>
  12. 12. How does it work? Browser HTTP Request TCP/IP Packet Network
  13. 13. How does it work? Server HTTP Request TCP/IP Packet Network HTML Output HTTP Response TCP/IP Packet
  14. 14. How does it work? Browser Network HTML Output HTTP Response TCP/IP Packet
  15. 15. Question <ul><li>If HTTP message is larger than TCP/IP packet’s max length, what will happen? </li></ul><ul><li>Is it possible to have more than one web site in the same server? How does it work? </li></ul><ul><li>How can we know the server’s IP address </li></ul>
  16. 16. TCP/IP <ul><li>Each TCP/IP connection </li></ul><ul><ul><li>Source IP </li></ul></ul><ul><ul><li>Source Port </li></ul></ul><ul><ul><li>Destination IP </li></ul></ul><ul><ul><li>Destination Port </li></ul></ul><ul><li>Reliable transmission </li></ul><ul><li>Establish connection before transmit </li></ul><ul><li>More overhead than UDP </li></ul>
  17. 17. Virtual Host <ul><li>Multi domain name in one server </li></ul><ul><li>Each domain name have their own content, files, resource and etc. separately </li></ul><ul><li>Domain name come from HTTP Request message </li></ul><ul><li>Where IP come from? </li></ul>
  18. 18. HTTP Persistent Connection <ul><li>Send multi HTTP Request in one connection </li></ul><ul><li>Why? </li></ul><ul><ul><li>Reduce overhead </li></ul></ul><ul><ul><li>Get response faster </li></ul></ul>
  19. 19. HTTP Session State <ul><li>HTTP is a stateless protocol </li></ul><ul><li>Web server implementation much easier and much more effective </li></ul><ul><li>Dynamic content? </li></ul><ul><li>Control session on application level </li></ul>
  20. 20. More detail about HTTP <ul><li>HTTP Header specification http :// en . wikipedia . org / wiki / List_of_HTTP_headers </li></ul><ul><li>HTTP Status code </li></ul><ul><li>HTTP Compression </li></ul><ul><ul><li>Reduce bandwidth </li></ul></ul><ul><ul><li>Use Content - Encoding </li></ul></ul>
  21. 21. Server concept Application HTTP Request HTTP Response
  22. 22. Server concept Web Server HTTP Request Request parameter Server Page Server Page Server Page Server Page Use URI pattern to select which page to run.. HTML Output + Response parameter HTTP Response
  23. 23. E.g. JSP Web Server Server Page Request Object Response Object
  24. 24. URL <ul><li>Uniform Resource Locators ( URLs ) are strings that specify how to access network resources, such as HTML documents . They are part of the more general class of Universal Resource Identifiers ( URIs ). The most important use of URLs is in HTML documents to identify the targets of hyperlinks . When using a Web browser such as Netscape, every highlighted region has a URL associated with it, which is accessed when the link is activated by a mouse click . Relative URLs specify only a portion of the full URL - the missing information is inferred though the context of the source document . </li></ul>
  25. 25. Secure Socket Layer <ul><li>Secure Sockets Layer ( SSL ), are cryptographic protocols that provide secure communications on the Internet for such things as web browsing , e - mail , Internet faxing , instant messaging and other data transfers. </li></ul><ul><li>URL pattern – https:// </li></ul><ul><li>For HTTP, normally use port 443 </li></ul><ul><li>More detail later </li></ul>
  26. 26. Web Cookie s <ul><li>HTTP cookies , sometimes known as web cookies or just cookies , are parcels of text sent by a server to a web browser and then sent back unchanged by the browser each time it accesses that server. HTTP cookies are used for authenticating , tracking, and maintaining specific information about users, such as site preferences and the contents of their electronic shopping carts . The term &quot;cookie&quot; is derived from &quot; magic cookie ,&quot; a well-known concept in unix computing which inspired both the idea and the name of HTTP cookies. </li></ul>
  27. 27. Web Cookies
  28. 28. Session <ul><li>Normally manage by web server </li></ul><ul><li>Use cookie to help keeping session id or session identifier </li></ul><ul><li>Session timeout, unused data will be cleared from memory </li></ul>
  29. 29. Session Browser Web Server Session ID Cookie Session Data Session Data Session Data Session Data Browser Session ID Cookie
  30. 30. Question <ul><li>If we close browser, will the cookie disappear ? </li></ul><ul><li>Can we change value in cookie manually? </li></ul><ul><li>How to open web site in a new session </li></ul><ul><ul><li>Open new browser window? </li></ul></ul>