cgi scripts
Download
Skip this Video
Download Presentation
CGI Scripts

Loading in 2 Seconds...

play fullscreen
1 / 13

CGI Scripts - PowerPoint PPT Presentation


  • 324 Views
  • Uploaded on

CGI Scripts. GET. Form data forms query string and is appended to the URL of the script Can be accessed by using the environment variable QUERY_STRING Browser or server may truncate data that exceeds an arbitrary number of characters. GET. GET request by client

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' CGI Scripts' - benita


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide2
GET
  • Form data forms query string and is appended to the URL of the script
    • Can be accessed by using the environment variable QUERY_STRING
    • Browser or server may truncate data that exceeds an arbitrary number of characters

CGI Scripts

slide3
GET
  • GET request by client

GET /cgi-bin/prog.pl?name= Bill+age=29 HTTP/1.0

Accept: www/source

Accept: text/html

Accept: text/plain

User-Agent: Lynx/2.4 libwww/2.14

CGI Scripts

slide4
GET
  • Can access CGI program with a query without using a form

<a href="/cgi-bin/prog.pl?name= Bill+age=29">CGI program</a>

  • Can also send extra path information
    • Usually file name

<a href="/cgi-bin/prog.pl/name= Bill+age=29">CGI program</a>

CGI Scripts

slide5
POST
  • Query length is unlimited
  • Script reads from standard input
  • Can\'t create canned queries

CGI Scripts

slide6
POST

POST /cgi-bin/prog.pl HTTP/1.0

Accept: www/source

Accept: text/html

Accept: text/plain

User-Agent: Lynx/2.4 libww/2.14

Content-type: application/x-www-form-urlencoded

Content-length: 22

user=Larry+Bird&age=30

CGI Scripts

decoding form data
Decoding Form Data
  • Determine request protocol by checking the REQUEST_METHOD environment variable
    • GET or POST
    • One script can work for both methods
  • If the protocol is GET, read query string from QUERY_STRING and/or the extra path information from PATH_INFO

CGI Scripts

decoding form data1
Decoding Form Data
  • If the protocol is POST, determine the size of the request using CONTENT_LENGTH and read that amount of data from the standard input
  • Split the query string on the \'&\' character, which separates key-value pairs
    • The format is key=value&key=value...

CGI Scripts

decoding form data2
Decoding Form Data
  • Decode the hexadecimal and \'+\' characters in each key-value pair
  • Create a key-value table with the key as the index

CGI Scripts

examples
Examples
  • Using forms with POST
    • Plain text
  • Guestbook
    • http://jupiter.cs.wayne.edu/~grosky/user-cgi/guestbook.pl?add using the GET method, will present a form for you to enter information

CGI Scripts

examples1
Examples
  • Guestbook
    • http://jupiter.cs.wayne.edu/~grosky/user-cgi/guestbook.pl using the GET method, will display the actual guestbook file [guestbook.htm]
    • Can open guestbook file directly by accessing http://jupiter.cs.wayne.edu/ ~grosky/CSC691/CGIScripts/ Guestbook/guestbook.htm

CGI Scripts

examples2
Examples
  • Guestbook
    • When form is submitted using the POST method, this program decodes the information and outputs a thank-you message

CGI Scripts

examples3
Examples
  • Survey
    • http://jupiter.cs.wayne.edu/~grosky/user-cgi/shopping.pl/start.htm
    • http://jupiter.cs.wayne.edu/ ~grosky/CSC691/CGIScripts/Hidden Fields/start.htm

CGI Scripts

ad