Web Server Design Week 16 Old Dominion University

Slides:



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

CGI. XML2 Common Gateway Interface n Georgia Tech 1995 Web Usage Survey –Perl % –C % –Shell Scripts - 8.1% –Tcl - Tool Commercial Language.
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.
1 ‘Dynamic’ Web Pages So far, we have developed ‘static’ web-pages, e.g., cv.html, repair.html and order.html. There is often a requirement to produce.
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.
Web Server Design Week 5 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/10/10.
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.
CSCE Systems Programming Lecture 21 Web Server: CGI -Dynamic Pages CSCE March 25, 2013.
Web Server Design Week 8 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 3/3/10.
Perl: Lecture 2 Advanced RE & CGI. Regular Expressions 2.
Web Server Design Week 4 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/03/10.
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.
Web Server Design Assignment #1: Basic Operations Due: 02/03/2010 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin.
Form Data Encoding GET – URL encoded POST – URL encoded
Internet and Intranet Fundamentals
Web Server Design Assignment #2: Conditionals & Persistence Due: 02/24/2010 Old Dominion University Department of Computer Science CS 495/595 Spring 2010.
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.
Web Server Design Week 6 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/17/10.
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.
Web Server Design Week 10 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 3/17/10.
Web Server Design Week 5 Old Dominion University Department of Computer Science CS 495/595 Spring 2012 Michael L. Nelson 02/07/12.
Web Programming Week 1 Old Dominion University Department of Computer Science CS 418/518 Fall 2007 Michael L. Nelson 8/27/07.
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 Server Design Week 6 Old Dominion University Department of Computer Science CS 495/595 Spring 2006 Michael L. Nelson 2/13/06.
Web Server Design Week 10 Old Dominion University
Web Server Design Week 4 Old Dominion University
Web Server Design Assignment #5: Unsafe Methods & CGI
Web Server Design Week 1 Old Dominion University
Web Server Design Assignment #2: Conditionals & Persistence
Web Server Design Week 8 Old Dominion University
Web Server Design Week 11 Old Dominion University
Web Server Design Week 7 Old Dominion University
CSCE Systems Programming
Introduction to CGI and ajax
Web Server Design Assignment #5 Extra Credit
Web Server Design Week 4 Old Dominion University
Web Server Design Week 12 Old Dominion University
Web Server Design Week 15 Old Dominion University
Web Server Design Week 5 Old Dominion University
Hypertext Transfer Protocol
Web Server Design Assignment #2: Conditionals & Persistence
Web Server Design Week 15 Old Dominion University
Web Server Design Week 8 Old Dominion University
Web Server Design Week 1 Old Dominion University
Web Server Design Week 8 Old Dominion University
Web Server Design Week 6 Old Dominion University
Web Server Design Week 10 Old Dominion University
Web Server Design Week 8 Old Dominion University
Web Server Design Week 11 Old Dominion University
The HTTP Protocol COSC 2206 Internet Tools The HTTP Protocol
Environment Variables
Web Server Design Week 5 Old Dominion University
Web Server Design Week 11 Old Dominion University
Web Server Design Week 4 Old Dominion University
Web Server Design Week 12 Old Dominion University
Web Server Design Week 12 Old Dominion University
Web Server Design Week 14 Old Dominion University
Web Server Design Assignment #1: Basic Operations
Web Server Design Week 6 Old Dominion University
Web Server Design Assignment #5 Extra Credit
Web Server Design Week 3 Old Dominion University
Web Server Design Week 7 Old Dominion University
Web Programming Week 1 Old Dominion University
Web Server Design Week 7 Old Dominion University
Presentation transcript:

Web Server Design Week 16 Old Dominion University Department of Computer Science CS 495/595 Spring 2006 Michael L. Nelson <mln@cs.odu.edu> 4/24/06

Common Gateway Interface A method for remotely invoking executable programs on a server A long-time convention http://hoohoo.ncsa.uiuc.edu/cgi/ finally defined in RFC 3875 foo.cgi GET /foo.cgi HTTP/1.1 client server 200 OK

CGI Invocation How Apache does it: http://httpd.apache.org/docs/2.0/mod/mod_cgi.html We’ll live slightly more dangerously: any executable (non-directory) file can be invoked as CGI with: POST GET w/ query string e.g. /a/b/c.cgi?var1=foo&var2=bar

CGI Operation The CGI program is responsible for returning (on STDOUT) some combination of its own headers: Content-type Location Status and other locally-defined headers Script-returned headers are: collected by the server processed; e.g.: “Location” -> HTTP/1.1 302 Found Status -> HTTP response code line combined with the server’s headers Resulting headers are returned to the client

Status % more status.cgi #!/usr/bin/perl print "Status: 678 This is not a real HTTP status code\n\n"; % telnet www.cs.odu.edu 80 Trying 128.82.4.2... Connected to xenon.cs.odu.edu. Escape character is '^]'. GET /~mln/teaching/cs595-s06/cgi/status.cgi HTTP/1.1 Host: www.cs.odu.edu HTTP/1.1 678 This is not a real HTTP status code Date: Mon, 24 Apr 2006 14:37:14 GMT Server: Apache/2 Content-Length: 0 Content-Type: text/plain Connection closed by foreign host.

Location % more location.cgi #!/usr/bin/perl print "Location: http://www.cs.odu.edu/~mln/\n\n"; % telnet www.cs.odu.edu 80 Trying 128.82.4.2... Connected to xenon.cs.odu.edu. Escape character is '^]'. GET /~mln/teaching/cs595-s06/cgi/location.cgi HTTP/1.1 Host: www.cs.odu.edu HTTP/1.1 302 Found Date: Mon, 24 Apr 2006 14:40:31 GMT Server: Apache/2 Location: http://www.cs.odu.edu/~mln/ Content-Length: 277 Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>302 Found</title> </head><body> <h1>Found</h1> <p>The document has moved <a href="http://www.cs.odu.edu/~mln/">here</a>.</p> <hr> <address>Apache/2 Server at www.cs.odu.edu Port 80</address> </body></html>

CGI Environment Section 4.1, RFC 3875 In practice, slightly different: AUTH_TYPE, CONTENT_LENGTH, CONTENT_TYPE, GATEWAY_INTERFACE, PATH_INFO, PATH_TRANSLATED, QUERY_STRING, REMOTE_ADDR, REMOTE_HOST, REMOTE_IDENT, REMOTE_USER, REQUEST_METHOD, SCRIPT_NAME, SERVER_NAME, SERVER_PORT, SERVER_PROTOCOL, SERVER_SOFTWARE In practice, slightly different: http://www.cs.odu.edu/~mln/teaching/cs595-s06/cgi/env.cgi

How to Customize the Environment? fork() & execve() Perl: set %ENV fork() & exec() Python: fork () & execve() Others??? please share w/ the list

ENV & CGI Examples {GET, POST} X {multipart/form-data, #!/usr/bin/perl print "Content-type: text/html\n\n"; foreach $key (keys (%ENV)) { print "$key = $ENV{$key} <br>\n"; } while (<STDIN>) { print "$_<br>\n"; {GET, POST} X {multipart/form-data, application/x-form-www-urlencoded} http://www.cs.odu.edu/~mln/teaching/cs595-s06/cgi/

Advanced Topics: “Soft 404s” foo.edu/lookup.php?key=123456 what http status code do you return if: script “lookup.php” exists and has no syntax errors but key 123456 is deleted or invalid Semantic events: http - 200 database - bad key reading: “Sic Transit Gloria Telae: Towards an Understanding of the Web’s Decay” http://www2004.org/proceedings/docs/1p328.pdf