Web Server Design Week 14 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 4/14/10.

Slides:



Advertisements
Similar presentations
HTTP HyperText Transfer Protocol. HTTP Uses TCP as its underlying transport protocol Uses port 80 Stateless protocol (i.e. HTTP Server maintains no information.
Advertisements

How does the server format the information it gives to the appln program? As environment variables and in standard input.
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.
Common Gateway Interface
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.
Ch27 - Common Gateway Interface (CGI) and Perl
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.
CGI Lecture 7 cs193i – Internet Technologies Summer 2004 Stanford University.
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 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.
Application Layer 2 Figures from Kurose and Ross
Copyright (c) 2010, Dr. Kuanchin Chen1 The Client-Server Architecture of the WWW Dr. Kuanchin Chen.
CSCE Systems Programming Lecture 21 Web Server: CGI -Dynamic Pages CSCE March 25, 2013.
Web Programming Week 1 Old Dominion University Department of Computer Science CS 418/518 Fall 2010 Martin Klein 8/31/10.
CGI programming Peter Verhás January What this tutorial is about Introduction to CGI programming Using ScriptBasic –Simple to program –Simple to.
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.
CGI Scripting and Vulnerabilities COEN 351: E-commerce Security.
Web Server Design Assignment #1: Basic Operations Due: 02/03/2010 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin.
Web Server Design Week 11 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 3/24/10.
1-1 HTTP request message GET /somedir/page.html HTTP/1.1 Host: User-agent: Mozilla/4.0 Connection: close Accept-language:fr request.
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 2 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 1/20/10.
Web Server Design Week 7 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 2/24/10.
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 15 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 4/21/10.
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.
CS 330 Class 8 Homework A pattern that contains a word with an optional period A pattern that contains Fred with a space (not Freddy) See regexp.txt guest4.htm.
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 Assignment #5: Unsafe Methods & CGI
Web Server Design Week 11 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 15 Old Dominion University
Web Server Design Week 5 Old Dominion University
Web Server Design Week 15 Old Dominion University
Web Server Design Week 6 Old Dominion University
Web Server Design Week 10 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 3 Old Dominion University
Web Server Design Week 16 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 7 Old Dominion University
Web Programming Week 1 Old Dominion University
MSc Internet Computing
Web Server Design Week 7 Old Dominion University
Presentation transcript:

Web Server Design Week 14 Old Dominion University Department of Computer Science CS 495/595 Spring 2010 Martin Klein 4/14/10

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

CGI Invocation How Apache does it: – 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/ 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"; mk$ telnet 80 Trying Connected to xenon.cs.odu.edu. Escape character is '^]'. GET /~mklein/teaching/cs595-s10/cgi/status.cgi HTTP/1.1 Host: Connection: close HTTP/ This is not a real HTTP status code Date: Wed, 14 Apr :55:05 GMT Server: Apache/ (Unix) DAV/2 PHP/ Content-Length: 0 Connection: close Content-Type: text/plain Connection closed by foreign host.

Location % more location.cgi #!/usr/bin/perl print "Location: mk$ telnet 80 Trying Connected to xenon.cs.odu.edu. Escape character is '^]'. GET /~mklein/teaching/cs595-s10/cgi/location.cgi HTTP/1.1 Host: Connection: close HTTP/ Found Date: Wed, 14 Apr :58:01 GMT Server: Apache/ (Unix) DAV/2 PHP/ Location: Content-Length: 309 Connection: close Content-Type: text/html; charset=iso Found Found The document has moved here. Apache/ (Unix) DAV/2 PHP/ Server at Port 80 Connection closed by foreign host.

Content-type % more ls.cgi #!/usr/bin/perl print "Content-type: text/plain\n\n"; $ls = `ls -alR`; print "$ls\n"; mk$ telnet 80 Trying Connected to xenon.cs.odu.edu. Escape character is '^]'. HEAD /~mklein/teaching/cs595-s10/cgi/ls.cgi HTTP/1.1 Host: Connection: close HTTP/ OK Date: Wed, 14 Apr :01:57 GMT Server: Apache/ (Unix) DAV/2 PHP/ Connection: close Content-Type: text/plain Connection closed by foreign host.

CGI Environment Section 4.1, RFC 3875 –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: –

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

ENV & CGI Examples #!/usr/bin/perl print "Content-type: text/html\n\n"; foreach $key (keys (%ENV)) { print "$key = $ENV{$key} \n"; } while ( ) { print "$_ \n"; } {GET, POST} X {multipart/form-data, application/x-form-www-urlencoded}

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