ISC440: Web Programming 2 Web Servers

Slides:



Advertisements
Similar presentations
Hypertext Transfer PROTOCOL ----HTTP Sen Wang CSE5232 Network Programming.
Advertisements

TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
HTTP – HyperText Transfer Protocol
HTTP By: Becky Fultz, Joe Flager, Katie Huston, Tom Packard, Allison Wilsey.
Hypertext Transfer Protocol Kyle Roth Mark Hoover.
HTTP Hypertext Transfer Protocol. HTTP messages HTTP is the language that web clients and web servers use to talk to each other –HTTP is largely “under.
How the web works: HTTP and CGI explained
World Wide Web1 Applications World Wide Web. 2 Introduction What is hypertext model? Use of hypertext in World Wide Web (WWW) – HTML. WWW client-server.
Chapter 2 Application Layer Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross Addison-Wesley, July.
Web, HTTP and Web Caching
HTTP Overview Vijayan Sugumaran School of Business Administration Oakland University.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
HyperText Transfer Protocol (HTTP) Review Carey Williamson iCORE Chair and Professor Department of Computer Science University of Calgary Slide content.
Hypertext Transport Protocol CS Dick Steflik.
PL-IV- Group A HTTP Request & Response Header
Rensselaer Polytechnic Institute CSC-432 – Operating Systems David Goldschmidt, Ph.D.
University of Calgary – CPSC 441 Parts of these slides are courtesy of Erich Nahum (IBM Research)
FTP (File Transfer Protocol) & Telnet
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
HyperText Transfer Protocol (HTTP).  HTTP is the protocol that supports communication between web browsers and web servers.  A “Web Server” is a HTTP.
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
Rensselaer Polytechnic Institute Shivkumar Kalvanaraman, Biplab Sikdar 1 The Web: the http protocol http: hypertext transfer protocol Web’s application.
Maryam Elahi University of Calgary – CPSC 441.  HTTP stands for Hypertext Transfer Protocol.  Used to deliver virtually all files and other data (collectively.
Web HTTP Hypertext Transfer Protocol. Web Terminology ◘Message: The basic unit of HTTP communication, consisting of structured sequence of octets matching.
HTTP1 Hypertext Transfer Protocol (HTTP) After this lecture, you should be able to:  Know how Web Browsers and Web Servers communicate via HTTP Protocol.
CPSC 4411 HTTP Protocol r Slides originally from Williamson at Calgary r Minor modifications are made.
2: Application Layer 1 Chapter 2: Application layer r 2.1 Principles of network applications  app architectures  app requirements r 2.2 Web and HTTP.
CITA 310 Section 2 HTTP (Selected Topics from Textbook Chapter 6)
Overview of Servlets and JSP
Computer Networks with Internet Technology William Stallings Chapter 04 Modern Applications 4.1 Web Access - HTTP.
COMP2322 Lab 2 HTTP Steven Lee Jan. 29, HTTP Hypertext Transfer Protocol Web’s application layer protocol Client/server model – Client (browser):
Week 11: Application Layer 1 Web and HTTP r Web page consists of objects r Object can be HTML file, JPEG image, Java applet, audio file,… r Web page consists.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
What’s Really Happening
Hypertext Transfer Protocol
Tiny http client and server
Block 5: An application layer protocol: HTTP
How HTTP Works Made by Manish Kushwaha.
HTTP – An overview.
Hypertext Transfer Protocol
The Hypertext Transfer Protocol
COMP2322 Lab 2 HTTP Steven Lee Feb. 8, 2017.
HTTP Protocol Specification
Hypertext Transport Protocol
Internet transport protocols services
Introduction Web Environments
Web Caching? Web Caching:.
HTTP Protocol.
Tutorial (4): HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
IS333D: MULTI-TIER APPLICATION DEVELOPMENT
WEB API.
Computer Communication & Networks
HTTP Review Carey Williamson Department of Computer Science
HTTP Hypertext Transfer Protocol
Net431:advanced net services
Hypertext Transfer Protocol
Hypertext Transfer Protocol
Hypertext Transfer Protocol
EE 122: HyperText Transfer Protocol (HTTP)
World Wide Web Uniform Resource Locator hostname [:port]/path
Hypertext Transfer Protocol
Kevin Harville Source: Webmaster in a Nutshell, O'Rielly Books
The HTTP Protocol COSC 2206 Internet Tools The HTTP Protocol
The Application Layer: HTTP

Carey Williamson Department of Computer Science University of Calgary
Traditional Internet Applications
HTTP Hypertext Transfer Protocol
Hypertext Transfer Protocol
CSCI-351 Data communication and Networks
Presentation transcript:

ISC440: Web Programming 2 Web Servers Dr. Abdullah Almutairi Spring 2016 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Introduction to HTTP HTTP: Hypertext Transfer Protocol http request http request Laptop w/ Netscape http response http response Desktop w/ Explorer Server w/ Apache HTTP: Hypertext Transfer Protocol Communication protocol between clients and servers Application layer protocol for WWW Client/Server model: Client: browser that requests, receives, displays object Server: receives requests and responds to them

How are Requests Generated? User clicks on something Uniform Resource Locator (URL): http://www.nytimes.com https://www.paymybills.com ftp://ftp.kernel.org news://news.deja.com telnet://gaia.cs.umass.edu mailto:nahum@us.ibm.com Different URL schemes map to different services Hostname is converted from a name to a 32-bit IP address (DNS resolve) Connection is established to server Most browser requests are HTTP requests. Web Servers: Implementation and Performance Erich Nahum

What Happens Then? Client downloads HTML document Sometimes called “container page” Typically in text format (ASCII) Contains instructions for rendering (e.g., background color, frames) Links to other pages Many have embedded objects: Images: GIF, JPG (logos, banner ads) Usually automatically retrieved I.e., without user involvement can control sometimes (e.g. browser options, junkbusters) <html> <head> <meta name=“Author” content=“Erich Nahum”> <title> Linux Web Server Performance </title> </head> <body text=“#00000”> <img width=31 height=11 src=“ibmlogo.gif”> <img src=“images/new.gif> <h1>Hi There!</h1> Here’s lots of cool linux stuff! <a href=“more.html”> Click here</a> for more! </body> </html> sample html file

Role of a Web Server? Respond to client requests, typically a browser Can be a proxy, which aggregates client requests (e.g., AOL) Could be search engine spider (e.g., Keynote) May have work to do on client’s behalf: Is the client’s cached copy still good? Is client authorized to get this document? Is client a proxy on someone else’s behalf? Run an arbitrary program (e.g., stock trade) Hundreds or thousands of simultaneous clients Hard to predict how many will show up on some day Many requests are in progress concurrently Server capacity planning is non-trivial.

What do HTTP Requests Look Like? GET /images/penguin.gif HTTP/1.0 User-Agent: Mozilla/0.9.4 (Linux 2.2.19) Host: www.kernel.org Accept: text/html, image/gif, image/jpeg Accept-Encoding: gzip Accept-Language: en Accept-Charset: iso-8859-1,*,utf-8 Cookie: B=xh203jfsf; Y=3sdkfjej <cr><lf> Messages are in ASCII (human-readable) Carriage-return and line-feed indicate end of headers Headers may communicate private information (e.g., browser, OS, cookie information, etc.)

What Kind of Requests are there? Called Methods: GET: retrieve a file (95% of requests) HEAD: just get meta-data (e.g., mod time) POST: submitting a form to a server PUT: store enclosed document as URI DELETE: removed named resource LINK/UNLINK: in 1.0, gone in 1.1 TRACE: http “echo” for debugging (added in 1.1) CONNECT: used by proxies for tunneling (1.1) OPTIONS: request for server/proxy options (1.1) Web Servers: Implementation and Performance Erich Nahum

What Do Responses Look Like? HTTP/1.0 200 OK Server: Tux 2.0 Content-Type: image/gif Content-Length: 43 Last-Modified: Fri, 15 Apr 1994 02:36:21 GMT Expires: Wed, 20 Feb 2002 18:54:46 GMT Date: Mon, 12 Nov 2001 14:29:48 GMT Cache-Control: no-cache Pragma: no-cache Connection: close Set-Cookie: PA=wefj2we0-jfjf <cr><lf> <data follows…> Similar format to requests (i.e., ASCII)

What Responses are There? 1XX: Informational (def’d in 1.0, used in 1.1) 100 Continue, 101 Switching Protocols 2XX: Success 200 OK, 206 Partial Content 3XX: Redirection 301 Moved Permanently, 304 Not Modified 4XX: Client error 400 Bad Request, 403 Forbidden, 404 Not Found 5XX: Server error 500 Internal Server Error, 503 Service Unavailable, 505 HTTP Version Not Supported

What are all these Headers? Specify capabilities and properties: General: Connection, Date Request: Accept-Encoding, User-Agent Response: Location, Server type Entity: Content-Encoding, Last-Modified Hop-by-hop: Proxy-Authenticate, Transfer-Encoding Server must pay attention to respond properly.

Summary: Introduction to HTTP The major application on the Internet Majority of traffic is HTTP (or HTTP-related) Client/server model: Clients make requests, servers respond to them Done mostly in ASCII text (helps debugging!) Various headers and commands

Outline of an HTTP Transaction We’ll talk about the basics of servicing an HTTP GET request from user space For this example, we'll assume a single process running in user space, similar to Apache 1.3 initialize; forever do { get request; process; send response; log request; } server in a nutshell

Readying a Server s = socket(); /* allocate listen socket */ bind(s, 80); /* bind to TCP port 80 */ listen(s); /* indicate willingness to accept */ while (1) { newconn = accept(s); /* accept new connection */ First thing a server does is notify the OS it is interested in WWW server requests; these are typically on TCP port 80. Other services use different ports (e.g., SSL is on 443) Allocate a socket and bind()'s it to the address (port 80) Server calls listen() on the socket to indicate willingness to receive requests Calls accept() to wait for a request to come in (and blocks) When the accept() returns, we have a new socket which represents a new connection to a client

Processing a Request getsockname() called to get the remote host name remoteIP = getsockname(newconn); remoteHost = gethostbyname(remoteIP); gettimeofday(currentTime); read(newconn, reqBuffer, sizeof(reqBuffer)); reqInfo = serverParse(reqBuffer); getsockname() called to get the remote host name for logging purposes (optional, but done by most) gethostbyname() called to get name of other end again for logging purposes gettimeofday() is called to get time of request both for Date header and for logging read() is called on new socket to retrieve request request is determined by parsing the data “GET /images/jul4/flag.gif” Web Servers: Implementation and Performance Erich Nahum

Processing a Request (cont) fileName = parseOutFileName(requestBuffer); fileAttr = stat(fileName); serverCheckFileStuff(fileName, fileAttr); open(fileName); stat() called to test file path to see if file exists/is accessible may not be there, may only be available to certain people "/microsoft/top-secret/plans-for-world-domination.html" stat() also used for file meta-data e.g., size of file, last modified time "Have plans changed since last time I checked?“ might have to stat() multiple files just to get to end e.g., 4 stats in bill g example above assuming all is OK, open() called to open the file Web Servers: Implementation and Performance Erich Nahum

Responding to a Request read(fileName, fileBuffer); headerBuffer = serverFigureHeaders(fileName, reqInfo); write(newSock, headerBuffer); write(newSock, fileBuffer); close(newSock); close(fileName); write(logFile, requestInfo); read() called to read the file into user space write() is called to send HTTP headers on socket (early servers called write() for each header!) write() is called to write the file on the socket close() is called to close the socket close() is called to close the open file descriptor write() is called on the log file