Lecture 19 Overview. Hyper Text Transfer Protocol HTTP is the protocol that supports communication between web browsers and web servers. – A “Web Server”

Slides:



Advertisements
Similar presentations
HTTP Cookies. CPSC Application Layer 2 User-server state: cookies Many major Web sites use cookies Four components: 1) cookie header line of HTTP.
Advertisements

HyperText Transfer Protocol (HTTP)
Hypertext Transfer Protocol Kyle Roth Mark Hoover.
Application Layer  We will learn about protocols by examining popular application-level protocols  HTTP  FTP  SMTP / POP3 / IMAP  Focus on client-server.
Chapter 2: Application Layer
HyperText Transfer Protocol (HTTP) Computer Networks Computer Networks Spring 2012 Spring 2012.
How the web works: HTTP and CGI explained
Lecture 7 TELNET Protocol & HyperText Transfer Protocol CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
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
Definitions, Definitions, Definitions Lead to Understanding.
1 K. Salah Module 2.1: Application Layer Application-level protocols provide high-level services –Web and HTTP –DNS –Electronic mail –Remote login –FTP.
Application Layer  We will learn about protocols by examining popular application-level protocols  HTTP  FTP  SMTP / POP3 / IMAP  Focus on client-server.
HTTP Overview Vijayan Sugumaran School of Business Administration Oakland University.
Lecture 13 Dynamic Web Servers & Common Gateway Interface CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
Hypertext Transport Protocol CS Dick Steflik.
Rensselaer Polytechnic Institute CSC-432 – Operating Systems David Goldschmidt, Ph.D.
HTTP; The World Wide Web Protocol
FTP (File Transfer Protocol) & Telnet
Mail (smtp), VoIP (sip, rtp)
HyperText Transfer Protocol (HTTP).  HTTP is the protocol that supports communication between web browsers and web servers.  A “Web Server” is a HTTP.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
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.
2: Application Layer1 CS 4244: Internet Software Development Dr. Eli Tilevich.
Rensselaer Polytechnic Institute Shivkumar Kalvanaraman, Biplab Sikdar 1 The Web: the http protocol http: hypertext transfer protocol Web’s application.
20-1 Last time □ NAT □ Application layer ♦ Intro ♦ Web / HTTP.
2: Application Layer1 Internet apps: their protocols and transport protocols Application remote terminal access Web file transfer streaming multimedia.
Week 11: Application Layer1 Web and HTTP First some jargon r Web page consists of objects r Object can be HTML file, JPEG image, Java applet, audio file,…
Introduction 1 Lecture 6 Application Layer (HTTP) slides are modified from J. Kurose & K. Ross University of Nevada – Reno Computer Science & Engineering.
2: Application Layer1 Web and HTTP First some jargon Web page consists of base HTML-file which includes several referenced objects Object can be HTML file,
1 Computer Communication & Networks Lecture 28 Application Layer: HTTP & WWW p Waleed Ejaz
Copyright (c) 2010, Dr. Kuanchin Chen1 The Client-Server Architecture of the WWW Dr. Kuanchin Chen.
Lecture 5 Dynamic Web Servers CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger.
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
HTTP Hypertext Transfer Protocol
HTTP Hypertext Transfer Protocol RFC 1945 (HTTP 1.0) RFC 2616 (HTTP 1.1)
HTTP Hypertext Transfer Protocol
1 HTTP EECS 325/425, Fall 2005 September Chapter 2: Application layer r 2.1 Principles of network applications m app architectures m app requirements.
Data Communications and Computer Networks Chapter 2 CS 3830 Lecture 8 Omar Meqdadi Department of Computer Science and Software Engineering University of.
Application Layer 2-1 Chapter 2 Application Layer 2.2 Web and HTTP.
CIS679: Lecture 13 r Review of Last Lecture r More on HTTP.
Netprog 2002 CGI Programming1 CGI Programming CLIENT HTTP SERVER CGI Program http request http response setenv(), dup(), fork(), exec(),...
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
Operating Systems Lesson 12. HTTP vs HTML HTML: hypertext markup language ◦ Definitions of tags that are added to Web documents to control their appearance.
Dr. Philip Cannata 1 The Web and HTTP. Dr. Philip Cannata 2 Application Layer 2-2 Chapter 2 Application Layer Computer Networking: A Top Down Approach.
Application Layer 2-1 Lecture 4: Web and HTTP. Web and HTTP First, a review… web page consists of objects object can be HTML file, JPEG image, Java applet,
Advance Computer Networks Lecture#05 Instructor: Engr. Muhammad Mateen Yaqoob.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Internet Applications (Cont’d) Basic Internet Applications – World Wide Web (WWW) Browser Architecture Static Documents Dynamic Documents Active Documents.
CS 6401 The World Wide Web Outline Background Structure Protocols.
IT 424 Networks2 IT 424 Networks2 Ack.: Slides are adapted from the slides of the book: “Computer Networking” – J. Kurose, K. Ross Chapter 2: Application.
EEC-484/584 Computer Networks Lecture 4 Wenbing Zhao (Part of the slides are based on Drs. Kurose & Ross ’ s slides for their Computer.
Application Layer 2-1 Chapter 2 Application Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012.
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.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 Chapter 22 World Wide Web (HTTP) Chapter 22 World Wide Web (HTTP) Mi-Jung Choi Dept. of Computer Science and Engineering
© Janice Regan, CMPT 128, Jan 2007 CMPT 371 Data Communications and Networking HTTP 0.
HTTP Protocol Amanda Burrows. HTTP Protocol The HTTP protocol is used to send HTML documents through the Internet. The HTTP protocol sends the HTML documents.
Lecture 5 Internet Core: Protocol layers. Application Layer  We will learn about protocols by examining popular application-level protocols  HTTP 
2: Application Layer 1 Chapter 2 Application Layer These ppt slides are originally from the Kurose and Ross’s book. But some slides are deleted and added.
Block 5: An application layer protocol: HTTP
WWW and HTTP King Fahd University of Petroleum & Minerals
HTTP request message: general format
Computer Communication & Networks
Chapter 27 WWW and HTTP.
HTTP Hypertext Transfer Protocol
HTTP Hypertext Transfer Protocol
Presentation transcript:

Lecture 19 Overview

Hyper Text Transfer Protocol HTTP is the protocol that supports communication between web browsers and web servers. – A “Web Server” is a HTTP server Most clients/servers today speak version 1.1, but 1.0 is also in use. “HTTP is an application-level protocol with the lightness and speed necessary for distributed, hypermedia information systems.” HTTP 2

HTTP overview Web’s application layer protocol client/server model – client: browser that requests, receives, “displays” Web objects – server: Web server sends objects in response to requests 3 PC running Explorer Server running Apache Web server Mac running Navigator HTTP request HTTP response

Request - Response HTTP has a simple structure: – client sends a request – server returns a reply HTTP can support multiple request-reply exchanges over a single TCP connection The “well known” TCP port for HTTP servers is port 80 – Other ports can be used as well HTTP 4

HTTP connections HTTP is “stateless” – server maintains no information about past client requests Nonpersistent HTTP – At most one object is sent over a TCP connection Persistent HTTP – Multiple objects can be sent over single TCP connection between client and server 5

Request Line Method URI HTTP-Version\r\n The request line contains 3 tokens (words) space characters “ ” separate the tokens HTTP 6 Request-Line Headers. Content... blank line

URI: Universal Resource Identifier URIs defined in RFC 2396 Absolute URI: – scheme://hostname[:port]/path – Relative URI: – /path – /blah/foo HTTP 7 No server mentioned

Request Method The Request Method can be: GETHEADDELETE PUT POSTTRACE OPTIONS future expansion is supported GET, HEAD and POST are supported everywhere HTTP 1.1 servers often support PUT, DELETE, OPTIONS & TRACE HTTP 8

Methods GET: retrieve information identified by the URI – Typically used to retrieve an HTML document HEAD: retrieve meta-information about the URI – used to find out if a document has changed POST: send information to a URI and retrieve result – used to submit a form HTTP 9

More Methods PUT: Store information in location named by URI DELETE: remove entity identified by URI TRACE: used to trace HTTP forwarding through proxies, tunnels, etc OPTIONS: used to determine capabilities of server, or characteristics of a named resource HTTP 10

The Header Lines Request Headers provide information to the server about the client – what kind of client – what kind of content will be accepted – who is making the request Each header line contains – an attribute name followed by a “:” followed by a space and the attribute value HTTP 1.1 requires a Host: header HTTP 11

End of the Headers Each header ends with a CRLF ( \r\n ) The end of the header section is marked with a blank line – just CRLF For GET and HEAD requests, the end of the headers is the end of the request! HTTP 12

HTTP request message format 13

POST A POST request includes some content (some data) after the headers – after the blank line There is no format for the data – just raw bytes A POST request must include a Content- Length line in the headers: – Content-length: 267 HTTP 14

HTTP Response ASCII Status Line Headers Section Content can be anything – not just text – typically an HTML document or some kind of image HTTP 15 Status-Line Headers. Content... blank line

Response Status Line HTTP-Version Status-Code Message Status Code is 3 digit number (for computers) – 1xxInformational – 2xxSuccess – 3xxRedirection – 4xxClient Error – 5xxServer Error Message is text (for humans) HTTP 16

Response Headers Provide the client with information about the returned entity (document) – what kind of document – how big the document is – how the document is encoded – when the document was last modified Response headers end with blank line HTTP 17

Content Content can be anything – sequence of raw bytes Content-Length header is required for any response that includes content Content-Type header also required HTTP 18

Single Request/Reply The client sends a complete request The server sends back the entire reply The server closes it’s socket If the client needs another document it must open a new connection HTTP 19 This was the default for HTTP 1.0

Persistent Connections HTTP 1.1 supports persistent connections – this is the default Multiple requests can be handled over a single TCP connection The Connection: header is used to exchange information about persistence (HTTP/1.1) 1.0 Clients used a Keep-alive: header HTTP 20

User-server state: cookies Four components: – 1) cookie header line of HTTP response message – 2) cookie header line in HTTP request message – 3) cookie file kept on user’s host, managed by user’s browser – 4) back-end database at Web site Cookies and privacy: – cookies permit sites to learn a lot about you – you may supply name and to sites 21

Cookies: keeping “state” 22 client server usual http response msg cookie file one week later: usual http request msg cookie: 1678 cookie- specific action access ebay 8734 usual http request msg Amazon server creates ID 1678 for user create entry usual http response Set-cookie: 1678 ebay 8734 amazon 1678 usual http request msg cookie: 1678 cookie- spectific action access ebay 8734 amazon 1678 backend database

Cookies (continued) What cookies can bring: – authorization – shopping carts – recommendations – user session state (Web ) How to keep “state”: – protocol endpoints: maintain state at sender/receiver over multiple transactions – cookies: http messages carry state 23

Web caches (proxy server) user sets browser: Web accesses via cache browser sends all HTTP requests to cache – object in cache: cache returns object – else cache requests object from origin server, then returns object to client 24 client Proxy server client HTTP request HTTP response HTTP request origin server origin server HTTP response Goal: satisfy client request without involving origin server

More about Web caching cache acts as both client and server typically cache is installed by ISP – university, company, residential ISP Why Web caching? reduce response time for client request reduce traffic on an institution’s access link. Internet dense with caches: enables “poor” content providers to effectively deliver content (but so does P2P file sharing) 25

Conditional GET Goal: don’t send object if cache has up-to-date cached version cache: specify date of cached copy in HTTP request – If-modified-since: server: response contains no object if cached copy is up-to-date: – HTTP/ Not Modified 26 cache server HTTP request msg If-modified-since: HTTP response HTTP/ Not Modified object not modified HTTP request msg If-modified-since: HTTP response HTTP/ OK object modified

Lecture 20 Dynamic Web Servers CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger

Web Server Talks HTTP Looks at METHOD, URI to determine what the client wants. For GET, URI often is just the path of a file – relative to some directory on the web server Dynamic Web Servers 28

GET /foo/blah Dynamic Web Servers 29 usrbinwwwetcfoofungif / blah

Dynamic Documents Dynamic Documents can provide: – automation of web site maintenance – customized advertising – database access – shopping carts – date and time service – … Dynamic Web Servers 30

Web Programming Writing programs that create dynamic documents has become very important There are a number of general approaches: – Create custom server for each service desired Each is available on different port. – Develop a real smart web server Server Side Includes, scripting, server APIs – Have web server run external programs Dynamic Web Servers 31

Custom Server Write a TCP server that watches a “well known” port for requests Develop a mapping from http requests to service requests Send back HTML (or whatever) that is created/selected by the server process Have to handle http errors, headers, etc Dynamic Web Servers 32

Drawbacks to Custom Server Approach We might have lots of ideas custom services – Each requires dedicated address (port) – Each needs to include: basic TCP server code parsing HTTP requests error handling headers access control Dynamic Web Servers 33

Smart Web Server Take a general purpose Web server (that can handle static documents) and – have it process requested documents as it sends them to the client The documents could contain commands that the server understands – the server includes some kind of interpreter Dynamic Web Servers 34

Example Smart Server Have the server read each HTML file as it sends it to the client The server could look for this: some command The server doesn’t send this part to the client, instead it interprets the command and sends the result to the client Everything else is sent normally Dynamic Web Servers 35

Server Side Includes Server Side Includes (SSI) provides a set of commands that a server will interpret Typically the server is configured to look for commands only in specially marked documents – so normal documents aren’t slowed down SSI commands are called directives – Directives are embedded in HTML comments Dynamic Web Servers 36

SSI Directives A comment looks like this: A directive looks like this: SSI servers keep a number of useful things in environment variables: DOCUMENT_NAME, DOCUMENT_URL echo: inserts the value of an environment variable into the page This page is located at Dynamic Web Servers 37

SSI Directives include: inserts the contents of a text file. flastmod: inserts the time and date that a file was last modified. Last modified: exec: runs an external program and inserts the output of the program. Current users: Dynamic Web Servers 38 Danger! Danger! Danger!

More Power Some servers support elaborate scripting languages Scripts are embedded in HTML documents, the server interprets the script: – Microsoft Active Server Pages (ASP) JScript, VBScript, PerlScript – Netscape LiveWire JavaScript, SQL connection library. – Many others… Dynamic Web Servers 39

Server Mapping and APIs Some servers include a programming interface that allows to extend the capabilities of the server by writing modules Specific URLs are mapped to specific modules instead of to files Dynamic Web Servers 40

External Programs Another approach is to provide a standard interface between external programs and web servers – We can run the same program from any web server – The web server handles all the http, we focus on the special service only – It doesn’t matter what language we use to write the external program Dynamic Web Servers 41

Common Gateway Interface CGI is a standard interface to external programs supported by most (if not all) web servers – CGI programs are often written in scripting languages (perl, tcl, etc.), The interface that is defined by CGI includes: – Identification of the service (i.e.,external program) – Mechanism for passing the request to the external program Dynamic Web Servers 42

Common Gateway Interface CGI is a standard mechanism for: – Associating URLs with programs that can be run by a web server – A protocol (of sorts) for how the request is passed to the external program – How the external program sends the response to the client CGI 43

CGI Programming CGI 44 CLIENT HTTP SERVER CGI Program http request http response setenv(), dup(), fork(), exec(),...

CGI URLs There is mapping between URLs and CGI programs provided by a web sever – The exact mapping is not standardized web server admin can set it up Typically: – requests that start with /CGI-BIN/, /cgi-bin/ or /cgi/, etc. not to static documents CGI 45

HTTP Server - CGI Interaction CGI 46 HTTP SERVER CGI Program stdin stdout Environment Variables

Environment Variables The web server sets some environment variables with information about the request The web server fork()s and the child process exec()s the CGI program The CGI program gets information about the request from environment variables CGI 47

STDIN, STDOUT Before calling exec(), the child process sets up pipes so that – stdin comes from the web server and – stdout goes to the web server In some cases part of the request is read from stdin Anything written to stdout is forwarded by the web server to the client CGI 48

Request Method: Get GET requests can include a query string as part of the URL: GET /cgi-bin/login?mgunes HTTP/1.0 CGI 49 Request Method Resource Name Delimiter Query String