This preview shows page 1. Sign up to view the full content.
Unformatted text preview: vironment variables that a CGI program can expect to be set when it runs. Figure 12.43 shows a subset. 652
Environment variable SERVER PORT REQUEST METHOD REMOTE HOST REMOTE ADDR CONTENT TYPE CONTENT LENGTH CHAPTER 12. NETWORK PROGRAMMING
Description Port that the parent is listening on GET or POST Domain name of client Dotted-decimal IP address of client POST only: MIME type of the request body POST only: Size in bytes of the request body Figure 12.43: Examples of CGI environment variables. Where Does the Child Send its Output?
A CGI program prints dynamic content to the standard output. Before the child process loads and runs the CGI program, it uses the Unix dup2 function to redirect standard output to the connected descriptor that is associated with the client. Thus, anything that the CGI program writes to standard output goes directly to the client.
Aside: Passing arguments to HTTP POST requests. For POST requests, the child would also need to redirect standard input to the connected des...
View Full Document
- Spring '10
- The American