Docsity

Network Programming III: Understanding HTTP, MIME, and Virtual Directories, Study notes of Windows Programming

Toggle sidebar
bg1
Network Programming Part III 3
29.5 HTTP
HTTP is a Stateless protocol.
• No information or “state” is maintained about previous HTTP requests
• Easier to implement than state-aware protocols
29.6 MIME
MIME stands for Multi-purpose Internet Mail Extensions.
MIME contains encoding features, 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.
29.7 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.
HTTP version 1.1 is derived from HTTP/1.1, Internet RFC 2616, Fielding, et al. 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.
29.8 Encoding and Decoding
HTTP is a Text Transport Protocol
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
29.9 Encoding Example Escape Sequence
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”);
docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Network Programming III: Understanding HTTP, MIME, and Virtual Directories and more Study notes Windows Programming in PDF only on Docsity!

29.5 HTTP

HTTP is a Stateless protocol.

  • No information or “state” is maintained about previous HTTP requests
  • Easier to implement than state-aware protocols

29.6 MIME

MIME stands for Multi-purpose Internet Mail Extensions.

MIME contains encoding features, 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.

29.7 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. HTTP version 1.1 is derived from HTTP/1.1, Internet RFC 2616, Fielding, et al. 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.

29.8 Encoding and Decoding

HTTP is a Text Transport Protocol 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

29.9 Encoding Example Escape Sequence

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”);

29.10 Virtual Directory

Represents the Home Directory of a Web Server

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 Virtual Directoy

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.

29.11 Web Browser Fetches a pages

  • http://www.vu.edu.pk/courses/win32.html
  • Hostname/DNS lookup for www.vu.edu.pk to get IP address
  • HTTP protocol uses port 80.
  • Connect to port 80 of the IP address discovered above!
  • Request the server for /courses/win32.html

29.12 HTTP Client Request

GET /courses/win32.html HTTP/1.

Request line is followed by 2 Carriage-Return /Line-feed sequences

Method Resource Identifier

HTTP

Version

Crlf

Crlf

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.

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.

MIME was defined in 1992 by the Internet Engineering Task Force (IETF). A new version, called S/MIME, supports encrypted messages.

29.15 HTTP Status codes

404 Not Found

  • requested document not found on this server 200 OK
  • request secceeded, requested object later in this message 400 Bad Request
  • request message not understood by server 302 Object Moved
  • requested document has been moved to some other location

29.16 HTTP Redirection

HTTP/1.1 302 Object Moved Location: http://www.vu.edu.pk

crlf

Most browsers will send another HTTP request to the new location, i.e. http://www.vu.edu.pk This is called Browser Redirection

29.17 HTTP Request per 1 TCP/IP Connection

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 generates one fresh HTTP request for each image specified in the HTML file

29.18 Server Architecture

Our server architecture will be based upon the following points

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

Many WinSock function calls e.g. accept() are blocking calls Server needs to serve up 5 clients simultaneously. Using other WinSock blocking calls, need to perform termination tasks for asynchronously terminating communication threads.

Summary

In this lecture, we studied some terms and their jobs. We studied HTTP (hyper text transfer protocol) which is used to transfer text data across the net work. We also studied HTML that is hyper text markup language which is simply a text script. Html is loaded in web browser and web browser translates the text and executes instruction written in form of text. For transferring media like image data and movie data, we overviewed MIME.

Note: For example and more information connect to Virtual University resource Online.

Exercises

  1. Create a chat application. Using that application, you should be able to chat with your friend on network.