Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 29 29. Lecture 29 Lecture Goals Development of a little Web Server Development of a little Web Server Web Server will server HTTP requests sent.

Similar presentations


Presentation on theme: "Lecture 29 29. Lecture 29 Lecture Goals Development of a little Web Server Development of a little Web Server Web Server will server HTTP requests sent."— Presentation transcript:

1 Lecture 29 29

2 Lecture 29 Lecture Goals Development of a little Web Server Development of a little Web Server Web Server will server HTTP requests sent via a Web Browser using URLs Web Server will server HTTP requests sent via a Web Browser using URLs URLs: http://www.vu.edu.pk/default.html http://www.vu.edu.pk/index.asp http://www.vu.edu.pk/win32.html http://www.vu.edu.pk/courses/win32.html URLs: http://www.vu.edu.pk/default.html http://www.vu.edu.pk/index.asp http://www.vu.edu.pk/win32.html http://www.vu.edu.pk/courses/win32.html http://www.vu.edu.pk/default.html http://www.vu.edu.pk/index.asp http://www.vu.edu.pk/win32.html http://www.vu.edu.pk/courses/win32.html http://www.vu.edu.pk/default.html http://www.vu.edu.pk/index.asp http://www.vu.edu.pk/win32.html http://www.vu.edu.pk/courses/win32.html

3 Lecture 29 Uniform Resource Locator Anatomy of a URL (Uniform Resource Locator): http://www.vu.edu.pk/courses/win32.html http:// Protocol www.vu.edu.pk vu.edu.pk server on World Wide Web /courses/win32.htmlwin32.html file in courses directory on that server Fetches an HTML file named win32.html from vu.edu.pk HTTP Server on the World Wide Web Anatomy of a URL (Uniform Resource Locator): http://www.vu.edu.pk/courses/win32.html http:// Protocol www.vu.edu.pk vu.edu.pk server on World Wide Web /courses/win32.htmlwin32.html file in courses directory on that server Fetches an HTML file named win32.html from vu.edu.pk HTTP Server on the World Wide Web http://www.vu.edu.pk/courses/win32.html www.vu.edu.pk http://www.vu.edu.pk/courses/win32.html www.vu.edu.pk

4 Lecture 29 HTML HTML – Hyper Text Mark-up Language HTML – Hyper Text Mark-up Language Contains text-formatting information e.g. font faces, font colours, font sizes, alignment etc. Contains text-formatting information e.g. font faces, font colours, font sizes, alignment etc. Contains HyperLinks: text that can be clicked to go to anothre HTML document on the Internet. Contains HyperLinks: text that can be clicked to go to anothre HTML document on the Internet. HTML tags are embedded within normal text to make it hypertext HTML tags are embedded within normal text to make it hypertext

5 Lecture 29 Web Browser HTTP Client – a Web Browser e.g. Microsoft Internet Explorer, Netscape Navigator HTTP Client – a Web Browser e.g. Microsoft Internet Explorer, Netscape Navigator Connect to your HTTP web server, requests a document, and displays in its window Connect to your HTTP web server, requests a document, and displays in its window

6 Lecture 29 HTTP Protocol HTTP – Originally developed by Physicists HTTP – Originally developed by Physicists Meant to share technical HyperText documents across locations Meant to share technical HyperText documents across locations Clickable HyperText is much easier to use instead of conventional sidebars and indices Clickable HyperText is much easier to use instead of conventional sidebars and indices Text-based protocol: meant to transport printable text-data and NOT binary data Text-based protocol: meant to transport printable text-data and NOT binary data

7 Lecture 29 HTTP Protocol HTTP is a Stateless protocol HTTP is a Stateless protocol No information or “state” is maintained about previous HTTP requests No information or “state” is maintained about previous HTTP requests Easier to implement than state-aware protocols Easier to implement than state-aware protocols

8 Lecture 29 Encoding and Decoding HTTP is a Text Transport Protocol HTTP is a Text Transport Protocol Transferring binary data over HTTP needs Data Encoding and Decoding because binary characters are not permitted Transferring binary data over HTTP needs Data Encoding and Decoding because binary characters are not permitted Similarly some characters are not permitted in a URL, e.g. SPACE. Here, URL encoding is used Similarly some characters are not permitted in a URL, e.g. SPACE. Here, URL encoding is used

9 Lecture 29 Encoding Example: Escape Sequences Including a Carriage Return / Line feed in a string printf(“Line One\nThis is new line”); Including a character in a string not found on our normal keyboards printf(“The funny character \xB2”);

10 Lecture 29 URL Anatomy of a URL (Uniform Resource Locator): http://www.vu.edu.pk/courses/win32.html http:// protocol www.vu.edu.pk Web Server courses/win32.htmllocation of file on server Anatomy of a URL (Uniform Resource Locator): http://www.vu.edu.pk/courses/win32.html http:// protocol www.vu.edu.pk Web Server courses/win32.htmllocation of file on server http://www.vu.edu.pk/courses/win32.html www.vu.edu.pk http://www.vu.edu.pk/courses/win32.html www.vu.edu.pk Or http://www.vu.edu.pk:80/.../.... :80 specifies Port Number to use for connection Or http://www.vu.edu.pk:80/.../.... :80 specifies Port Number to use for connectionhttp://www.vu.edu.pk:80/.../

11 Lecture 29 Virtual Directory / rerpresents the Home Directory of a Web Server / rerpresents the Home Directory of a Web Server IIS (Internet Information Server) has c:\inetpub\wwwroot\ as its default Home Directory IIS (Internet Information Server) has c:\inetpub\wwwroot\ as its default Home Directory Here, /courses/ either corresponds to a Physical Directory c:\inetpub\wwwroot\courses OR a Virtual Directoy (contd.) Here, /courses/ either corresponds to a Physical Directory c:\inetpub\wwwroot\courses OR a Virtual Directoy (contd.)

12 Lecture 29 Virtual Directory (contd.) In a Web Server, we may specify that /courses/ will represent some other physical directory on the Web Server like D:\MyWeb\. Then /courses/ will be a Virtual Directory. In a Web Server, we may specify that /courses/ will represent some other physical directory on the Web Server like D:\MyWeb\. Then /courses/ will be a Virtual Directory. In Windows2000 and IIS 5.0 (Internet Information Server), a folder’s “Web Sharing…” is used to create a Virtual Directory for any folder. In Windows2000 and IIS 5.0 (Internet Information Server), a folder’s “Web Sharing…” is used to create a Virtual Directory for any folder.

13 Lecture 29 A Web Browser fetches a page … http://www.vu.edu.pk/courses/win32.html http://www.vu.edu.pk/courses/win32.html Hostname/DNS lookup for www.vu.edu.pk to get IP address Hostname/DNS lookup for www.vu.edu.pk to get IP addresswww.vu.edu.pk HTTP protocol uses port 80. Connect to port 80 of the IP address discovered above! HTTP protocol uses port 80. Connect to port 80 of the IP address discovered above! Request the server for /courses/win32.html Request the server for /courses/win32.html How? How?

14 Lecture 29 HTTP Client Request GET /courses/win32.html HTTP/1.0 GET /courses/win32.html HTTP/1.0 Request line is followed by 2 Carriage-Return /Line-feed sequences Request line is followed by 2 Carriage-Return /Line-feed sequences Method Resource Identifier HTTP version crlf

15 Lecture 29 HTTP Server Response HTTP/1.1 200 OK HTTP/1.1 200 OK Content-type: text/html Content-type: text/html Content-length: 2061 Content-length: 2061 Actual data follows the headers Actual data follows the headers HTTP version Status CodeDescription crlf } Status Line Headers delimited by CR/LF sequence

16 Lecture 29 File extensions File extensions are non-standard across different platforms and can not be used to determine the type of contents of any file. File extensions are non-standard across different platforms and can not be used to determine the type of contents of any file.

17 Lecture 29 MIME In an HTTP response, a Web Server tells the browser MIME type of data being sent In an HTTP response, a Web Server tells the browser MIME type of data being sent MIME type is used by the browser to handle the data appropriately i.e. show an image, display HTML etc. MIME type is used by the browser to handle the data appropriately i.e. show an image, display HTML etc.

18 Lecture 29 File extensions and MIME Different common MIME types image/gifGIF image image/jpegJPEG image text/htmlHTML document text/plainplain text Different common MIME types image/gifGIF image image/jpegJPEG image text/htmlHTML document text/plainplain text

19 Lecture 29 HTTP Request Headers HTTP request may also contain quite a few headers sent by the browser HTTP request may also contain quite a few headers sent by the browser HTTP Request Headers usually contain information about the browser type, client’s IP address, screen resolution etc. HTTP Request Headers usually contain information about the browser type, client’s IP address, screen resolution etc.

20 Lecture 29 MIME MIME: Multi-purpose Internet Mail Extensions MIME: Multi-purpose Internet Mail Extensions MIME Encoding features were added to enable transfer of binary data, e.g. images (GIF, JPEG etc.) via mail. MIME Encoding features were added to enable transfer of binary data, e.g. images (GIF, JPEG etc.) via mail. Using MIME encoding HTTP can now transfer complex binary data, e.g. images and video Using MIME encoding HTTP can now transfer complex binary data, e.g. images and video

21 Lecture 29 RFC Short for Request for Comments, a series of notes about the Internet, started in 1969 (when the Internet was the ARPANET). An Internet Document can be submitted to the IETF by anyone, but the IETF decides if the document becomes an RFC. Eventually, if it gains enough interest, it may evolve into an Internet standard. Short for Request for Comments, a series of notes about the Internet, started in 1969 (when the Internet was the ARPANET). An Internet Document can be submitted to the IETF by anyone, but the IETF decides if the document becomes an RFC. Eventually, if it gains enough interest, it may evolve into an Internet standard.Internet ARPANETIETFstandardInternet ARPANETIETFstandard HTTP version 1.1 is derived from HTTP/1.1, Internet RFC 2616, Fielding, et al. HTTP version 1.1 is derived from HTTP/1.1, Internet RFC 2616, Fielding, et al.HTTP/1.1 Each RFC is designated by an RFC number. Once published, an RFC never changes. Modifications to an original RFC are assigned a new RFC number. Each RFC is designated by an RFC number. Once published, an RFC never changes. Modifications to an original RFC are assigned a new RFC number.

22 Lecture 29 MIME encoding MIME: Short for Multipurpose Internet Mail Extensions, a specification for formatting non-ASCII messages so that they can be sent over the Internet. MIME: Short for Multipurpose Internet Mail Extensions, a specification for formatting non-ASCII messages so that they can be sent over the Internet.ASCIIInternetASCIIInternet Enables us to send and receive graphics, audio, and video files via the Internet mail system. Enables us to send and receive graphics, audio, and video files via the Internet mail system. There are many predefined MIME types, such as GIF graphics files and PostScript files. It is also possible to define your own MIME types. There are many predefined MIME types, such as GIF graphics files and PostScript files. It is also possible to define your own MIME types.GIFPostScriptGIFPostScript In addition to e-mail applications, Web browsers also support various MIME types. This enables the browser to display or output files that are not in HTML format. In addition to e-mail applications, Web browsers also support various MIME types. This enables the browser to display or output files that are not in HTML format.Web browsersWeb browsers MIME was defined in 1992 by the Internet Engineering Task Force (IETF). A new version, called S/MIME, supports encrypted messages. MIME was defined in 1992 by the Internet Engineering Task Force (IETF). A new version, called S/MIME, supports encrypted messages.Internet Engineering Task Force (IETF)S/MIME,Internet Engineering Task Force (IETF)S/MIME,

23 Lecture 29 HTTP Status codes 404 Not Found - requested document not found on this server 404 Not Found - requested document not found on this server 200 OK - request secceeded, requested object later in this message 200 OK - request secceeded, requested object later in this message 400 Bad Request - request message not understood by server 400 Bad Request - request message not understood by server 302 Object Moved - requested document has been moved to some other location 302 Object Moved - requested document has been moved to some other location

24 Lecture 29 HTTP Redirection HTTP/1.1 302 Object Moved HTTP/1.1 302 Object Moved Location: http://www.vu.edu.pk Location: http://www.vu.edu.pk Most browsers will send another HTTP request to the new location, i.e. http://www.vu.edu.pk Most browsers will send another HTTP request to the new location, i.e. http://www.vu.edu.pkhttp://www.vu.edu.pk This is called Browser Redirection This is called Browser Redirection crlf

25 Lecture 29 1 HTTP Request per 1 TCP/IP connection HTML text is received in one HTTP request from the Web Server HTML text is received in one HTTP request from the Web Server Browser reads all the HTML web page and paints its client area according to the HTML tags specified. Browser reads all the HTML web page and paints its client area according to the HTML tags specified. Browser generates one fresh HTTP request for each image specified in the HTML file Browser generates one fresh HTTP request for each image specified in the HTML file

26 Lecture 29 Server Architecture Ability to serve up to 5 clients simultaneously Ability to serve up to 5 clients simultaneously Multi-threaded HTTP Web Server Multi-threaded HTTP Web Server 1 thread dedicated to accept client connections 1 thread dedicated to accept client connections 1 thread per client to serve HTTP requests 1 thread per client to serve HTTP requests 1 thread dedicated to perform termination housekeeping of communication threads 1 thread dedicated to perform termination housekeeping of communication threads Use of Synchronisation Objects Use of Synchronisation Objects

27 Lecture 29 Server Architecture: Whey threads? Many WinSock function calls e.g. accept() are blocking calls Many WinSock function calls e.g. accept() are blocking calls Need to serve up to 5 clients simultaneously using other WinSock blocking calls Need to serve up to 5 clients simultaneously using other WinSock blocking calls Need to perform termination tasks for asynchronously terminating communication threads Need to perform termination tasks for asynchronously terminating communication threads


Download ppt "Lecture 29 29. Lecture 29 Lecture Goals Development of a little Web Server Development of a little Web Server Web Server will server HTTP requests sent."

Similar presentations


Ads by Google