The HTTP Protocol http://www.w3.org/Protocols/ COSC 2206 Internet Tools The HTTP Protocol http://www.w3.org/Protocols/

Slides:



Advertisements
Similar presentations
CGI & HTML forms CGI Common Gateway Interface  A web server is only a pipe between user-agents  and content – it does not generate content.
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
How does the server format the information it gives to the appln program? As environment variables and in standard input.
1 HTTP – HyperText Transfer Protocol Part 1. 2 Common Protocols In order for two remote machines to “ understand ” each other they should –‘‘ speak the.
How the web works: HTTP and CGI explained
Definitions, Definitions, Definitions Lead to Understanding.
Outcomes Know what are CGI Environment Variables Know how to use environment variables How to process A simple Query Form Able to use URL Encoding rules.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
Web Client/Server Communication A290/A590, Fall /09/2014.
Overview A plain HTML document is static A CGI program is executed in real-time, so that it can output dynamic information. CGI (Common Gateway Interface)
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
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.
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.
TCP/IP Protocol Suite 1 Chapter 22 Upon completion you will be able to: World Wide Web: HTTP Understand the components of a browser and a server Understand.
Maryam Elahi University of Calgary – CPSC 441.  HTTP stands for Hypertext Transfer Protocol.  Used to deliver virtually all files and other data (collectively.
Form Data Encoding GET – URL encoded POST – URL encoded
WWW: an Internet application Bill Chu. © Bei-Tseng Chu Aug 2000 WWW Web and HTTP WWW web is an interconnected information servers each server maintains.
Appendix E: Overview of HTTP ©SoftMoore ConsultingSlide 1.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
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)
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1 Fundamentals.
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.
Overview of Servlets and JSP
Computer Networks with Internet Technology William Stallings Chapter 04 Modern Applications 4.1 Web Access - HTTP.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
INTRODUCTION Dr Mohd Soperi Mohd Zahid Semester /16.
What’s Really Happening
Hypertext Transfer Protocol
Tiny http client and server
Block 5: An application layer protocol: HTTP
Web Protocols and Practice
WWW and HTTP King Fahd University of Petroleum & Minerals
HTTP – An overview.
Hypertext Transfer Protocol
The Hypertext Transfer Protocol
Web Development Web Servers.
Computing with C# and the .NET Framework
COMP2322 Lab 2 HTTP Steven Lee Feb. 8, 2017.
Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
HTTP Protocol Specification
Hypertext Transport Protocol
TCP/IP Networking An Example
HTTP Protocol.
Tutorial (4): HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
IS333D: MULTI-TIER APPLICATION DEVELOPMENT
HTTP Hypertext Transfer Protocol
Hypertext Transfer Protocol
1.1 A Brief Intro to the Internet
Hypertext Transfer Protocol
HyperText Transfer Protocol
EE 122: HyperText Transfer Protocol (HTTP)
William Stallings Data and Computer Communications
World Wide Web Uniform Resource Locator hostname [:port]/path
Hypertext Transfer Protocol
Kevin Harville Source: Webmaster in a Nutshell, O'Rielly Books
Environment Variables
An Example of a TCP/IP Application: the World Wide Web
HTTP Hypertext Transfer Protocol
Hypertext Transfer Protocol
CSCI-351 Data communication and Networks
MSc Internet Computing
Presentation transcript:

The HTTP Protocol http://www.w3.org/Protocols/ COSC 2206 Internet Tools The HTTP Protocol http://www.w3.org/Protocols/

What is TCP/IP? TCP: Transmission Control Protocol IP: Internet Protocol These network protocols provide a standard method for sending and receiving messages over the Internet/ HTTP sits on top of TCP/IP as an application layer protocol that provides client-server communication. 4/5/2019 BGA

What is HTTP? Hypertext Transport Protocol (1.1) It is the protocol that web servers and clients use to communicate on the internet. The web client is normally a browser on a client machine. Web server is a server such as Apache that receives HTTP requests from a client and sends an HTTP response back to a client. 4/5/2019 BGA

Try this using windows telnet Run apache telnet localhost 80 ^] to get prompt (control + ]) ? to get help (there is an open command) o localhost 80 GET /index.html HTTP/1.1 Host: localhost Now press enter to see HTTP response This is the HTTP request 4/5/2019 BGA

blank line is important HTTP Response HTTP/1.1 200 OK Date: Tue, 22 Jun 2004 14:20:03 GMT Server: Apache/1.3.29 (Win32) PHP/4.3.7 Last-Modified: Sat, 06 Dec 2003 15:38:57 GMT ETag: "0-76-3fd1f811" Accept-Ranges: bytes Content-Length: 118 Content-Type: text/html <html> <head><title>My Home Page</title></head> <body> <h1>My Home Page</h1> <img src="apache_pb.gif"> </body> </html> HTTP response headers blank line is important 4/5/2019 BGA

Client/Server communication Web Server (e.g. Apache) Web Client (browser) HTTP Response HTTP Request 4/5/2019 BGA

Uniform Resource Locator Client uses URL to inform server what resourse is requested (also a universal resource location). Format is scheme://host:port/path?queryString#fragment Examples: http://localhost:8080/index.html http://www.cs.laurentian.ca/test.php?name=bob The default port is 80 and isn't specified 4/5/2019 BGA

Virtual Path The path part of a URL is a virtual path and does not need to be a path on the server's file system Example http://localhost:8080/test/servlet/HelloWorld Here the actual directory on the server for the HelloWorld servlet on my computer is c:/tomcat/webapps/test/WEB-INF/classes 4/5/2019 BGA

Absolute Path absolute path (absolute URL) Example completely specifies the path to a resource using a complete URL Example http://www.cs.laurentian.ca/c1046/assign5.html 4/5/2019 BGA

Relative Path (no leading /) Given a document whose absolute URL is http://www.cs.laurentian.ca/badams/c2206/test.html Suppose this document contains the links <a href="test.php">...</a> <a href="jsp/index.html">...</a> Then the absolute URL's are http://www.cs.laurentian.ca/badams/c2206/test.php http://www.cs.laurentian.ca/badams/c2206/jsp/index.html 4/5/2019 BGA

Relative Path (leading /) Given a document whose absolute URL is http://www.cs.laurentian.ca/badams/c2206/test.html Suppose this document contains the links <a href="/test.php">...</a> <a href="/jsp/index.html">...</a> Then the absolute URL's are http://www.cs.laurentian.ca/test.php http://www.cs.laurentian.ca/jsp/index.html 4/5/2019 BGA

Query String (1) The query string is an encoded string of name value pairs with the format ?name1=value1&name2=value2& ... URL encoding is needed to include special characters such as =, # and /. Each special character is encoded as %HH where HH is the hex representation Spaces can be encoded as + characters or as %2B 4/5/2019 BGA

Query String (2) Encode the characters ; / ? : @ & = + $ , space character: + or %2B delimiters: < > # % " others: { } | \ ^ [ ] ` In PHP there is a special function called rawurlencode that can do this. Other web languages have similar functions. 4/5/2019 BGA

Query String (3) In a GET request from a client the name-value pairs are sent to the server and are made available to a script such as a PHP script, or to a Java servlet. The other way to send values to the server that does not use a query string is using a POST request. More on GET and POST later 4/5/2019 BGA

The HTTP Request The client sends information to the server using an HTTP request. There are three ways to send the request click on a link in an HTML document that corresponds to a URL on the server: can either retrieve document or execute script type a URL into the browsers location or address field Click on a form submission button 4/5/2019 BGA

HTTP Request Methods The most important methods are GET HEAD POST There are several other methods that are not often used: DELETE, OPTION, TRACE, PUT 4/5/2019 BGA

HTTP GET Method Request to retrieve a document or execute a script Not supposed to modify data stored on the web server or in an associated database Used to return static or dynamic HTML documents and images, results of database queries. Can be bookmarked since query string is part of the URL. 4/5/2019 BGA

HTTP HEAD Method Request information about a document such as its last modified date so browser can decide whether to fetch it from server or from cache It's like a GET request but no document is sent back by the server. 4/5/2019 BGA

HTTP POST Method Used in conjunction with HTML forms to send form data (name-value pairs) to the server. After the blank line at end of headers the form data is sent as name-value pairs. Use this method if data stored on the server is modified (e.g, rows in database table) Cannot be bookmarked. 4/5/2019 BGA

Name value pairs separated by a colon Example HTTP Request GET index.html HTTP/1.1 Host: localhost Accept: image/gif, image/jpg, */* Accept-Language: en Connection: Keep-Alive User-Agent: browser info goes here Name value pairs separated by a colon 4/5/2019 BGA

Request Headers Accept Accept-Charset Accept-Encoding Accept-Language MIME types the browser will accept Accept-Charset the character sets the browser understands Accept-Encoding Encodings such as gzip that browser accepts Accept-Language languages such as en that browser accepts 4/5/2019 BGA

Request Headers Authorization Connection Content-length Username/password of browser user Connection indicates if browser can handle persistent connections for multiple file/image requests Content-length number of bytes in request content: used only by POST request to give size of post data being sent on server's standard input stream 4/5/2019 BGA

Request Headers Cookie Host If-Modified-Since Returns name/value pair to server that was set by server on a previous connection. Host The hostname of the target (required) If-Modified-Since page should be send only if it has been modified since the specified date 4/5/2019 BGA

Request Headers If-Unmodified-Since Referer User-Agent opposite of If-Modified-Since (for PUT requests) Referer URL that referred user to specified resource The spelling mistake must be made (Use Referer not Referrer) User-Agent information on browser making the request 4/5/2019 BGA

Example HTTP Response HTTP/1.1 200 OK Date: date information goes here status line HTTP/1.1 200 OK Date: date information goes here Server: Apache/1.3.23 (Unix) Last-Modified: date info goes here Content-Length: 141 Content-Type: text/html HTML document index.html goes here blank line necessary 4/5/2019 BGA

Server Response Status Codes 100-199: informational codes 200-299: The request was successful 300-309: File has moved Location header indicates the new address 301 means that browser will automatically submit a new request for the redirected resource 400-499: Client error was made 500-599: Server error was made 4/5/2019 BGA

Common Status Codes 200 OK 204 No Content 301 Moved Permanently Successful request for a document The document is included in the response 204 No Content 301 Moved Permanently 302 Found (Location header) 404 Not Found 500 Internal Server Error 4/5/2019 BGA

MIME Types Multi-part internet mail extensions Examples: text/plain, text/html image/gif, image/jpg, image/png application/x-gzip application/zip 4/5/2019 BGA

Response Headers Allow Cache-Control Connection request methods such as GET, POST that server supports Cache-Control various options for client side caching Connection whether to use persistent connections or not 4/5/2019 BGA

Response Headers Content-Encoding Content-Language Content-Base gzip, for example Content-Language language of the document Content-Base base URL used to resolve relative URL's in the document 4/5/2019 BGA

Response Headers Content-Length Content-Type Expires Length in bytes of the response's content Content-Type Media type e.g., text/plain, text/html, or image/jpg Expires for a document that changes frequently this tells broswer not to use a cached version 4/5/2019 BGA

Response Headers Last-Modified Location Refresh when the document was last changed. Useful in caching Location new document address Refresh refresh document again after specified number of seconds 4/5/2019 BGA

Response Headers Retry-After Server Set-Cookie how soon to repeat document request Server Name and version of the Web server Set-Cookie request to have browser set a cookie and return it on future requests 4/5/2019 BGA

Response Headers WWW-Authenticate Specifies the authorization scheme and the realm 4/5/2019 BGA

CGI Common Gateway Interface The original way for servers to provide dynamic content by executing external server-side scripts (e.g. Perl) Server provides script with an environment Script provides the dynamic page Inefficient since a new process is started on the server for each client request 4/5/2019 BGA

CGI CGI Script Server Browser environment vars working directory files, if any Response: HTML Doc Some headers response content on standard output Request Browser 4/5/2019 BGA

CGI Environment Variables (1) DOCUMENT_ROOT Root directory of your web server HTTP_COOKIE Client's cookie, if one has been set HTTP_HOST The host name of the web server HTTP_REFERER URL of page that called your script 4/5/2019 BGA

CGI Environment Variables (2) HTTP_USER_AGENT Client's browser type string HTTPS indicates if script is invoked by a secure server PATH Path to your server QUERY_STRING string of name value pairs sent by client 4/5/2019 BGA

CGI Environment Variables (3) REMOTE_ADDR IP address of the client REMOTE_HOST IP address or hostname of the client REMOTE_PORT Port tht client is connected to REMOTE_USER client's user name if applicable 4/5/2019 BGA

CGI Environment Variables (4) REQUEST_METHOD GET or POST REQUEST_URI Document path relative to document root SCRIPT_FILENAME Full path name of the script SCRIPT_NAME path relative to document root 4/5/2019 BGA

CGI Environment Variables (5) SERVER_ADMIN email address of server's web master SERVER_NAME The URL of the server SERVER_PORT Port number on which server is listening SERVER_SOFTWARE String describing the server software and version 4/5/2019 BGA