Common Gateway Interface CGI

Similar documents
The HTTP Protocol HTTP

Outline. Lecture 8: CGI (Common Gateway Interface ) Common Gateway Interface (CGI) CGI Overview

Common Gateway Interface

You can also set the expiration time of the cookie in another way. It may be easier than using seconds.

Forms, CGI. HTML forms. Form example. Form example...

COSC 2206 Internet Tools. The HTTP Protocol

Forms, CGI. Cristian Bogdan 2D2052 / 2D1335 F5 1

Outline of Lecture 5. Course Content. Objectives of Lecture 6 CGI and HTML Forms

Crystal Enterprise 8 - ASP vs. CSP

Web History. Systemprogrammering 2006 Föreläsning 9 Web Services. Internet Hosts. Web History (cont) 1945: 1989: Topics 1990:

NETB 329 Lecture 13 Python CGI Programming

Giving credit where credit is due

PYTHON CGI PROGRAMMING

Chapter 17 : Internet Publishing

Dynamic Documents. Kent State University Dept. of Math & Computer Science. CS 4/55231 Internet Engineering. What is a Script?

Using SAS/IntrNet Software

Server-Side Web Programming: Python (Part 1) Copyright 2017 by Robert M. Dondero, Ph.D. Princeton University

Accessibility (1A) Young Won Lim 8/22/13

Web Search An Application of Information Retrieval Theory

Forms, CGI. Objectives

Web Engineering. Basic Technologies: Protocols and Web Servers. Husni

CS105 Perl: Perl CGI. Nathan Clement 24 Feb 2014

Class (1A) Young Won Lim 9/8/14

Server Deployment Release Notes

USQ/CSC2406 Web Publishing

Binary Search Tree (3A) Young Won Lim 6/2/18

Web Services April 24, 2007

Binary Search Tree (2A) Young Won Lim 5/17/18

Web Recommendations for Mobile Web Browsing

World Wide Web, etc.

Internet and Web Based Technology.

JSON POST WITH PHP IN ANGULARJS

Binary Search Tree (3A) Young Won Lim 6/4/18

Functions (4A) Young Won Lim 5/8/17

FPGA Configuration (1C) Young Won Lim 12/1/13

LING 408/508: Computational Techniques for Linguists. Lecture 21

Tiny CPU Data Path (2B) Young Won Lim 5/2/16

Serving dynamic content. Issues in serving dynamic content. add.com: THE Internet addition portal! CGI. Page 2

Oracle HTTP Server. mod_plsql User's Guide 10g Release 2 (10.2) B

The following is a sample statement. Perl statements end in a semi-colon (;):

Functions (4A) Young Won Lim 3/16/18

Polymorphism Overview (1A) Young Won Lim 2/20/18

RAM (1A) Young Won Lim 11/12/13

JavaScript (5A) JavaScript

Implementing a Web Server on OS/390: Part III Writing Common Gateway Interfaces and Installing Java Virtual Machine

CGI Architecture Diagram. Web browser takes response from web server and displays either the received file or error message.

Haskell Overview III (3A) Young Won Lim 10/4/16

Binary Search Tree (3A) Young Won Lim 6/6/18

Monad Background (3A) Young Won Lim 11/20/17

Using OAuth 2.0 to Access ionbiz APIs

3. WWW and HTTP. Fig.3.1 Architecture of WWW

PIC 40A. Lecture 19: PHP Form handling, session variables and regular expressions. Copyright 2011 Jukka Virtanen UCLA 1 05/25/12

jquery Basic HTTP communication

Course Topics. The Three-Tier Architecture. Example 1: Airline reservations. IT360: Applied Database Systems. Introduction to PHP

Chapter 1 FORMS. SYS-ED/ Computer Education Techniques, Inc.

Common Gateway Interface for SIP

Common Gateway Interface for SIP

HTTP. EC512 Spring /15/2015 EC512 - Prof. Thomas Skinner 1

Operators (2A) Young Won Lim 10/2/13

COMP 520 Fall 2013 The WIG language (1) The. language

COMP 520 Fall 2010 The WIG language (1) The. language

Package Rook. February 15, 2013

Pointers (1A) Young Won Lim 11/1/17

Threat Landscape 2017

Intrusion detection and prevention system: CGI attacks.

How browsers talk to servers. What does this do?

AN4965 Application note

CSC309: Introduction to Web Programming. Lecture 8

Structure (1A) Component

CS637 Midterm Review

Fachgebiet Technische Informatik, Joachim Zumbrägel

Internet and Web Technologies. Sample Solutions 2013

HTML forms and the dynamic web

Chapter 2. Application Layer

Chapter 27 WWW and HTTP Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

First Simple Interactive JSP example

Java Applets, etc. Instructor: Dmitri A. Gusev. Fall Lecture 25, December 5, CS 502: Computers and Communications Technology

Oracle Application Server 10g

Chapter 8 Writing NOI Agents

Wrapping CGI Scripts. Managing CGI Development Security on Apache. Gunther Birznieks

OpenQM. Building a CGI Web Server. Martin Phillips Ladybridge Systems Ltd

Algorithms (7A) Young Won Lim 4/10/17

Web Security: Vulnerabilities & Attacks

Eulerian Cycle (2A) Young Won Lim 4/26/18

Applications of Pointers (1A) Young Won Lim 12/26/17

Composer Help. Web Request Common Block

Web technologies. Web. basic components. embellishments in browser. DOM (document object model)

Algorithms (7A) Young Won Lim 4/18/17

SPL Assignment 4

HTTP Request Handling

Algorithms Bubble Sort (1B) Young Won Lim 4/5/18

Copyright by Object Computing, Inc. (OCI). All rights reserved. Strata

Pointers (1A) Young Won Lim 1/5/18

Pointers (1A) Young Won Lim 1/9/18

Shankersinh Vaghela Bapu Institue of Technology

IT2353 WEB TECHNOLOGY Question Bank UNIT I 1. What is the difference between node and host? 2. What is the purpose of routers? 3. Define protocol. 4.

Master Syndication Gateway V2. User's Manual. Copyright Bontrager Connection LLC

Authentication for Web Services. Ray Miller Systems Development and Support Computing Services, University of Oxford

Database Systems Fundamentals

UFCEKG Lecture 4 Server Side Scripting & PHP

Transcription:

Common Gateway Interface CGI

Copyright (c) 2013-2015 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Please send corrections (or suggestions) to youngwlim@hotmail.com. This document was produced by using OpenOffice and Octave.

Common Gateway Interface CGI specifies how the HTTP server interfaces with an external program (gateway) 4 interface components (a) command line (b) environment variables (c) standard input (d) standard output forms of the command line when the server calls the gateway these values are transmitted to the gateway sent to the gateway sent to the server CGI (1A) 3

The Output of CGI CGI uses standard output Content-Type: MIME-type empty line MIME standard content types text image audio video multipart application message CGI (1A) 4

HTTP Transactions 1. Connection 2. Query 3. Processing 4. Response 5. Termination A query line has 3 parts: a query method local path of the requested resource an HTTP version number A response line has 3 parts: an HTTP version number a status code a textual description of the status CGI (1A) 5

HTML Forms Form Handling Client side languages: Javascript Server side languages: PHP, JSP form.html <html> <body> <form action="form_handler" method="get"> User Name: <input name="user" type="text" /> <input type="submit" /> </form> </body> </html> form_handler.php <html> <body> <?php // This will print whatever the user put $name = $_GET['user']; echo "Hello, ". $name."!";?> </body> </html> form_handler.cpp <html> <body> Hello, world! </body> </html> CGI (1A) 6

HTTP Transactions A CGI script in a special directory : cgi-bin obtains URL-encoded query data access command-line arguments access environment variables through standard input for the POST method through the QUERY_STRING environment var for the GET method standard output goes to the server 1. Connection 2. Query 3. Processing 4. Response 5. Termination 1. process command-line arguments 2. obtain form's input data 3. process the input data 4. send a response through a standard output 5. terminate CGI (1A) 7

Intermediate Nodes Server specific variables: SERVER_SOFTWARE: name/version of HTTP server. SERVER_NAME: host name of the server, may be dot-decimal IP address. GATEWAY_INTERFACE: CGI/version. Request specific variables: SERVER_PROTOCOL: HTTP/version. SERVER_PORT: TCP port (decimal). REQUEST_METHOD: name of HTTP method (see above). PATH_INFO: path suffix, if appended to URL after program name and a slash. PATH_TRANSLATED: corresponding full path as supposed by server, if PATH_INFO is present. SCRIPT_NAME: relative path to the program, like /cgi-bin/script.cgi. QUERY_STRING: the part of URL after? character. The query string may be composed of *name=value pairs separated with ampersands (such as var1=val1&var2=val2...) when used to submit form data transferred via GET method as defined by HTML application/x-www-form-urlencoded. REMOTE_HOST: host name of the client, unset if server did not perform such lookup. REMOTE_ADDR: IP address of the client (dot-decimal). AUTH_TYPE: identification type, if applicable. REMOTE_USER used for certain AUTH_TYPEs. REMOTE_IDENT: see ident, only if server performed such lookup. CGI (1A) 8

Intermediate Nodes CONTENT_TYPE: Internet media type of input data if PUT or POST method are used, as provided via HTTP header. CONTENT_LENGTH: similarly, size of input data (decimal, in octets) if provided via HTTP header. Variables passed by user agent ( HTTP_ACCEPT, HTTP_ACCEPT_LANGUAGE, HTTP_USER_AGENT, HTTP_COOKIE and possibly others) contain values of corresponding HTTP headers and therefore have the same sense. CGI (1A) 9

Making HTML pages by C++ Html.cpp Html.hpp welcometime.cpp welcometime.o: Html.h welcome: Html.o welcometime.o $(CC) Html.o welcometime.o -o welcome runwelcome: welcome./welcome CGI (1A) 10

main() leader() send() trailer() CGI (1A) 11

leader() and trailer() In main()c Class Html Constructor P.S. Wang, Standard C++ with objected-oriented programming CGI (1A) 12

sendfile() and send() Read file and write it into standard output CGI (1A) 13

Class Html header file CGI (1A) 14

HTML File Output CGI (1A) 15

CGI (1A) 16

Tokenizer Tokenizer.cpp Tokenizer.hpp testtokenizer.cpp CGI (1A) 17

testtokenizer.cpp (1) CGI (1A) 18

testtokenizer.cpp (2) CGI (1A) 19

testtokenizer.cpp (2) CGI (1A) 20

Tokenizer.hpp CGI (1A) 21

Tokenizer.cpp (1) string::npos -1, the end of a string find_first_not_of(str, pos) search for the first character that does not match any of the characters specified in str beginning at the position pos CGI (1A) 22

Tokenizer.cpp (2) CGI (1A) 23

CGI (1A) 24

HTTP Request and Response FormData.cpp FormData.hpp Tokenizer.cpp Tokenizer.hpp testformdata.cpp FORMOBJ = FormData.o Tokenizer.o testformdata.o testform: $(FORMOBJ) $(CC) $(FORMOBJ) -o testform runform: testform export REQUEST_METHOD=POST; export CONTENT_LENGTH=94; \./testform < line CGI (1A) 25

HTTP Request and Response CGI (1A) 26

HTTP Request and Response CGI (1A) 27

HTTP Request and Response CGI (1A) 28

HTTP Request and Response file line in makefile CGI (1A) 29

HTTP Request and Response CGI (1A) 30

HTTP Request and Response CGI (1A) 31

HTTP Request and Response CGI (1A) 32

HTTP Request and Response http://stackoverflow.com/questions/238547/how-do-you-programmatically-download-a-webpage-in-java CGI (1A) 33

CGI (1A) 34

Reference References [1] http://en.wikipedia.org/ [2] P.S. Wang, Standard C++ with objected-oriented programming CGI (1A) 35