How does the server format the information it gives to the appln program? As environment variables and in standard input.

Slides:



Advertisements
Similar presentations
CS 22: Enhanced Web Site Design - Week 8Slide 1 of 15 Enhanced Web Site Design Stanford University Continuing Studies CS 22 Mark Branom
Advertisements

A digression The next feature of programming HTTP clients that we will consider is user authentication Before considering that, however, we will digress.
CGI & HTML forms CGI Common Gateway Interface  A web server is only a pipe between user-agents  and content – it does not generate content.
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
Common Gateway Interface (CGI). CGI is a protocol: CGI is not a programming language CGI is a protocol for the exchange of information between between.
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
Configuring Apache Server and Perl for CGI T.A. Maisa Khudair Dr. Qusai Abu Ein.
CGI. XML2 Common Gateway Interface n Georgia Tech 1995 Web Usage Survey –Perl % –C % –Shell Scripts - 8.1% –Tcl - Tool Commercial Language.
The abs_path in a URI If the abs_path is not present in the URL, it must be given as "/" in a Request-URI for a resource. Thus, if a user points a browser.
What is CGI? The Common Gateway Interface (CGI) is a mechanism that allows Web clients to execute programs on a Web server and to receive their output.
Domain Name System: DNS
CP476 Internet Computing Browser and Web Server 1 Web Browsers A client software program that allows you to access and view Web pages on the Internet –Examples.
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.
HTTP Overview Vijayan Sugumaran School of Business Administration Oakland University.
The abs_path in a URI If the abs_path is not present in the URL, it must be given as "/" in a Request-URI for a resource. Thus, if a user points a browser.
Hypertext Transport Protocol CS Dick Steflik.
Client, Server, HTTP, IP Address, Domain Name. Client-Server Model Client Bob Yahoo Server yahoo.com/finance.html A text file named finance.html.
 What is it ? What is it ?  URI,URN,URL URI,URN,URL  HTTP – methods HTTP – methods  HTTP Request Packets HTTP Request Packets  HTTP Request Headers.
1 Web Servers Web Protocols and Practice Chapter 4.
Web Client/Server Communication A290/A590, Fall /09/2014.
Common Gateway Interface
Web server and web browser It’s a take and give policy in between client and server through HTTP(Hyper Text Transport Protocol) Server takes a request.
1 Homework / Exam Exam 3 –Solutions Posted –Questions? HW8 due next class Final Exam –See posted schedule Websites on UNIX systems Course Evaluations.
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)
CP3024 Lecture 3 Server Side Facilities. Lecture contents  Server side includes  Common gateway interface (CGI)  PHP Hypertext Preprocessor (PHP) pages.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
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.
Web Server Design Week 14 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 4/14/10.
ITIS 1210 Introduction to Web-Based Information Systems Chapter 23 How Web Host Servers Work.
USING PERL FOR CGI PROGRAMMING
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 7: HTTP and CGI Fundamentals of Web Programming.
CSCE Systems Programming Lecture 21 Web Server: CGI -Dynamic Pages CSCE March 25, 2013.
Web Client-Server Server Client Hypertext link TCP port 80.
ELECTRONIC COMMERCE- Framework, Technologies and Applications © Tata McGraw-Hill 1 Electronic Commerce: Information Publishing Technology.
Perl CGI What is "CGI"? Common Gateway Interface A means of running an executable program via the Web. Perl have a *very* nice interface to create CGI.
1-1 HTTP request message GET /somedir/page.html HTTP/1.1 Host: User-agent: Mozilla/4.0 Connection: close Accept-language:fr request.
LinuxChix Apache. Serving Webpages The layer 7 protocol (HTTP) is what our browsers talk to get us the websites we can't seem to live without. HTTP is.
Form Data Encoding GET – URL encoded POST – URL encoded
Internet and Intranet Fundamentals
Copyright © 2002 ProsoftTraining. All rights reserved. Java Servlets.
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)
Web Server Design Week 13 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 4/7/10.
Krerk Piromsopa. 1 Department of Computer Engineering. Chulalongkorn University. Web Application Generic Issues.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
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.
Web Server Design Assignment #5: Unsafe Methods & CGI Due: 05/05/2010 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin.
Introduction to CGI PROG. CGI stands for Common Gateway Interface. CGI is a standard programming interface to Web servers that gives us a way to make.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
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.
Web Server Design Week 13 Old Dominion University Department of Computer Science CS 495/595 Spring 2012 Michael L. Nelson 04/03/12.
Web Server Design Week 15 Old Dominion University Department of Computer Science CS 495/595 Spring 2009 Michael L. Nelson 4/20/09.
Web Server Design Week 3 Old Dominion University Department of Computer Science CS 495/595 Spring 2006 Michael L. Nelson 1/23/06.
Web Protocols and Practice
Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Web Server Design Assignment #5: Unsafe Methods & CGI
CSCE Systems Programming
IS333D: MULTI-TIER APPLICATION DEVELOPMENT
Application layer Lecture 7.
Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
The HTTP Protocol COSC 2206 Internet Tools The HTTP Protocol
Environment Variables
Web Server Design Week 16 Old Dominion University
Presentation transcript:

How does the server format the information it gives to the appln program? As environment variables and in standard input

Example Suppose you were to send the request below from interzone interzone.ucc.ie> telnet student.cs.ucc.ie 80 Trying Connected to student.cs.ucc.ie. Escape character is '^]'. GET /cs1064/jabowen/cgi-bin/respond.cgi/extra/path/info.txt?city=cork&man=fred HTTP/1.1 Host: student.cs.ucc.ie The application program, respond.cgi, would receive the environment variables shown on the next slide On the subsequent slides, we will consider where the values of these environment variables come from

QUERY_STRING city=cork&man=fred SERVER_ADDR SERVER_PROTOCOL HTTP/1.1 PATH_TRANSLATED /usr/local/www/docs/extra/path/info.txt REMOTE_PORT 3719 GATEWAY_INTERFACE CGI/1.1 HTTP_HOST student.cs.ucc.ie PATH_INFO /extra/path/info.txt SERVER_SOFTWARE Apache/ (Unix) PHP/4.0.3pl1 SERVER_ADMIN REMOTE_ADDR SCRIPT_NAME /cs1064/jabowen/cgi-bin/respond.cgi SERVER_NAME student.cs.ucc.ie DOCUMENT_ROOT /usr/local/www/docs REQUEST_URI /cs1064/jabowen/cgi bin/respond.cgi/extra/path/info.txt?city=cork&man=fred SCRIPT_FILENAME /usr/local/www/docs/cs1064/jabowen/cgi-bin/respond.cgi REQUEST_METHOD GET PATH /bin:/usr/bin:. SERVER_PORT 80

How does the server pass the information it received in the HTTP request line? Remember that the request line contains a request method, a URI and a HTTP version The request method is passed to the appln program in an environment variable called REQUEST_METHOD The request-URI is passed to the appln program in an environment variable called REQUEST_URI The HTTP version is passed to the appln program in an environment variable called SERVER_PROTOCOL

Cs 4320 got here on 21 jan 2005

How does the server pass the information it received in HTTP headers? This information is sent to the application program through environment variables With two exceptions (see later), the names of these variables are derived from the names of the HTTP headers, by preceding each header name with HTTP_ Examples are on the next slide

Examples For example, consider the request header Host: student.cs.ucc.ie This is relayed by the server onto the appln program as the following environment variable and value HTTP_HOST student.cs.ucc.ie Even non-standard headers are treated the same way. For example, suppose that, when a human telnets to a HTTP server, he sends the non-standard header Grocery-Order: rashers This is relayed to the appln program as HTTP_GROCERY_ORDER rashers Note that hyphens in HTTP headers are converted to underscores in the names of environment variables

How does the server pass the HTTP message body (if any)? Remember that not all HTTP request messages contain message bodies But if a request message does have a body, this is passed to the appln program through standard input For example, a request which uses the POST method does have a message body, containing data captured in a HTML form –the form data are passed to the application program in standard input The environment variable CONTENT_LENGTH specifies the number of bytes of data the message body in standard input contains

How does the server pass the message body (contd.) For requests which have message bodies (such as POST and PUT requests), the type of the data in the message body is given in the environment variable CONTENT_TYPE Thus, CONTENT_TYPE and CONTENT_LENGTH are exceptions to the rule that HTTP header values are passed in environment variables in whose names the header names are preceded by HTTP_

What other information does the server pass to the appln program? The HTTP server demon uses the following environment variables to send other information (besides the content of the HTTP request) to the application program:  SERVER_SOFTWARE Name and version of HTTP server software  SERVER_NAME and/or SERVER_ADDR The hostname and/or IP address of the server machine.  SERVER_PORT The TCP/IP port being used by the HTTP server demon. SERVER_ADMIN address of the server’s system administrator, if available

Other information passed by server (contd.)  GATEWAY_INTERFACE Version of CGI protocol in use. Format: CGI/revision  REMOTE_ADDR IP address of the client machine  REMOTE_HOST Domain name of the client machine, if available.  REMOTE_PORT Port number on the client machine which sent the request, if available.

Other information passed by server (contd.)  DOCUMENT_ROOT This environment variables is not always passed by servers but, when it is used, it contains the path, within the directory structure on the server machine, to the top of the sub-tree from which the HTTP demon serves documents. For example, an application program running on student.cs.ucc.ie would receive DOCUMENT_ROOT /usr/local/www/docs because all web documents on this machine are stored in this branch of the directory tree. For example, the file whose URL is is actually stored at /usr/local/www/docs/cs1064/jabowen/welcome.htm

Other information passed by server (contd.)  PATH_INFO Contains any additional “path” info which was appended, in the Request-URI, to the name of the application program Example Consider the following HTTP request GET /cs1064/jabowen/cgi-bin/respond.cgi/extra/path/info.txt?city=cork&man=fred HTTP/1.1 Host: student.cs.ucc.ie The server recognizes that the application program is respond.cgi so it passes the string /extra/path/info.txt in the environment variable PATH_INFO PATH_INFO /extra/path/info.txt

Other information passed by server (contd.) The information which appears in PATH_INFO also appears in another variable, called PATH_TRANSLATED PATH_TRANSLATED contains the complete path from the root directory of the machine For example, if DOCUMENT_ROOT /usr/local/www/docs and PATH_INFO /extra/path/info.txt then PATH_TRANSLATED /usr/local/www/docs/extra/path/info.txt

Other information passed by server (contd.)  QUERY_STRING This environment variable is used to pass the information which follows the ? in the Request-URI Example HTTP Request GET /cs1064/jabowen/cgi-bin/respond.cgi/extra/path/info.txt?city=cork&man=fred HTTP/1.1 Host: student.cs.ucc.ie The server sets QUERY_STRING as follows: QUERY_STRING city=cork&man=fred

Other information passed by server (contd.) SCRIPT_FILENAME Full path and name, relative to the root directory of the server machine, of the CGI script SCRIPT_NAME Path and name, relative to the DOCUMENT_ROOT of the server demon, of the CGI script

Other information passed by server (contd.) AUTH_TYPE If the server supports user authentication, and the script is protected, this is the protocol-specific authentication method used to validate the user. REMOTE_USER If the server supports user authentication, and the script is protected, this is the username they have authenticated as. REMOTE_IDENT If the HTTP server supports RFC 931 identification, then this variable will be set to the remote user name retrieved from the server. Usage of this variable should be limited to logging only.

Other information passed by server (contd.) Any other environment variables that exist in the environment of the “user” which is running the server Example: PATH /bin:/usr/bin:.

Cs 4320 got here on 10 feb 2004