Other Headers

A CGI script can supply other HTTP headers in addition to Content-Type. In most cases, the server passes these extra headers to the client without executing them. For example, the following Refresh header redirects the client to a new location after a specified amount of time:

Refresh: "5; URL = http://www.deitel.com/newpage.html"

Five seconds after the Web browser receives this header, the browser requests the resource at the specified URL. Alternatively, the Refresh header can omit the URL, in which case it will refresh the current page after the given time has expired.

The CGI specification indicates that certain types of headers output by a CGI script are to be handled by the server, rather than be passed directly to the client. The first of these is the Location header. Like Refresh, Location redirects the client to a new location:

Location: http://www.deitel.com/newpage.html

If used with a relative (or virtual) URL (i.e., Location: /newpage.html), the Location header indicates to the server that the redirection is to be performed on the server side without sending the Location header back to the client. In this case, it appears to the user as if the document rendered in the Web browser was the resource the user requested, when in fact the document rendered is the resource specified in the Location header.

The CGI specification also includes a Status header, which instructs the server to output a specified status header line (such as HTTP/1.1 200 OK). Normally, the server will send the appropriate status line to the client (adding, for example, the 200 OK status line in most cases). However, CGI allows programmers to change the response status. For example, sending a

 Status: 204 No Response

header indicates that, although the request was successful, the client should not display a new page in the browser window. This header might be useful if you want to allow users to submit forms without relocating to a new page.

We have now covered the fundamentals of the CGI specification. To review, CGI allows scripts to interact with servers in three basic ways:

  1. through the output of headers and content to the server via standard output
  2. by the server's setting of environment variables (including the URL-encoded QUERY_STRING) whose values are available within the script (via getenv)
  3. through POSTed, URL-encoded data that the server sends to the script's standard input.

Introduction to Computers, the Internet and World Wide Web

Introduction to C++ Programming

Introduction to Classes and Objects

Control Statements: Part 1

Control Statements: Part 2

Functions and an Introduction to Recursion

Arrays and Vectors

Pointers and Pointer-Based Strings

Classes: A Deeper Look, Part 1

Classes: A Deeper Look, Part 2

Operator Overloading; String and Array Objects

Object-Oriented Programming: Inheritance

Object-Oriented Programming: Polymorphism


Stream Input/Output

Exception Handling

File Processing

Class string and String Stream Processing

Web Programming

Searching and Sorting

Data Structures

Bits, Characters, C-Strings and structs

Standard Template Library (STL)

Other Topics

Appendix A. Operator Precedence and Associativity Chart

Appendix B. ASCII Character Set

Appendix C. Fundamental Types

Appendix D. Number Systems

Appendix E. C Legacy Code Topics

Appendix F. Preprocessor

Appendix G. ATM Case Study Code

Appendix H. UML 2: Additional Diagram Types

Appendix I. C++ Internet and Web Resources

Appendix J. Introduction to XHTML

Appendix K. XHTML Special Characters

Appendix L. Using the Visual Studio .NET Debugger

Appendix M. Using the GNU C++ Debugger


show all menu

C++ How to Program
C++ How to Program (5th Edition)
ISBN: 0131857576
EAN: 2147483647
Year: 2004
Pages: 627
Similar book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net