Topics

User Functions

Older Stories


Welcome to myCobol.net Friday, 18 August 2017, 20:16 @ CEST

CGI configuration

cgi for cobol
  • Friday, 17 June 2016, 16:25 @ CEST
  • Contributed by:
  • Views:
    309

The compiler that accepts the syntax, uses a library that handles the CGI protocol. This cgi library can be tuned for your needs by environment variables, as follows:

 

CGI_AUTO_HEADER

This variable allows you to suppress the output of the HTML header.  
Set CGI_AUTO_HEADER to 0 (off, false, no) if you want to suppress the output of the HTML header. 
This can be useful when you want to execute a CGI program and include its output into an existing flow of HTML text. 
For example, with server-side includes, or SSI, you can instruct the Web server to execute a subprogram in the manner of CGI and then incorporate its output right into the HTML document before sending it to the requesting client. 
The default value is 1 (on, true, yes).  

CGI_CLEAR_MISSING_VALUES

This variable allows you to control the behaviour of the ACCEPT statement when CGI variables do not exist in the CGI input data.  
By default, ACCEPT sets the value of numeric data items to zero and non-numeric data items to spaces if a CGI variable does not exist. 
Set the CGI_CLEAR_MISSING_VALUES configuration variable to 0 (off, false, no) if you do not want ACCEPT to change the value of the data item if the corresponding CGI variable is missing from the CGI input data.  

CGI_CONTENT_TYPE

By default, the output generated by your CGI program is mapped as HTML content. 
To associate your CGI output with a MIME content type other than text/html, use the CGI_CONTENT_TYPE configuration variable. 
This variable lets you control the content type information in the header of output files created by GnuCobol. Such information informs the browser of the type of content that they are about to receive.  
Using this variable, you can configure your CGI program for many types of output, including eXtensible Markup Language (XML) or Wireless Markup Language (WML) for Wireless Application Protocol (WAP) devices like mobile phones.  
Whichever format you choose, the US-ASCII character set is applied to the output by default. 
If you want the CGI output to be mapped to an alternate character set such as ISO-8859-I (Western European), then you can specify the encoding set to use with the variable as well.  

Include this variable in your runtime environment as follows:  
export CGI_CONTENT_TYPE="content-type; charset=encoding_set"  

Where content-type is the MIME content type of the generated output, and encoding_set is the preferred character encoding set to use.  

For example, the WML content type for WAP mobile phones is text/vnd.wap.wml.  
To associate your CGI output with WML, include the following in your runtime environment:  
export CGI_CONTENT_TYPE=text/vnd.wap.wml  

If you want your WML output to be mapped to the Western European character set, include the following:
export CGI_CONTENT_TYPE="text/vnd.wap.wml; charset=iso-8859-I" 

The content type for eXtensible Markup Language (XML) documents is "text/xml".  
If your program generates XML data, include the following:  
export CGI_CONTENT_TYPE=text/xml  

CGI_NO_CACHE

This variable allows you to choose whether the HTML output of your Common Gateway Interface (CGI) program will be cached by the requesting client.  
The default value is 1 (on, true, yes), which means there is no caching. 
By default, the runtime generates *Pragma: no-cache * in the HTML response header that gets sent to the standard output stream. 
If you set CGI_NO_CACHE to 0 (off, false, no), the runtime suppresses this line of the response header, and the requesting client caches the output.  

CGI_STRIP_CR

When this variable is set to 1 (on, true, yes), the runtime automatically removes carriage return characters from data entered in HTML TEXTAREAS (multiple line entry-fields). 
Stripping the carriage returns from this kind of input prevents double-spacing problems, as well as conflicts that may arise if the data is used in a context that does not expect a carriage return character to precede each line feed character. 
Some browsers send a carriage return line feed sequence to the CGI program, and when this sequence is written to a file on operating systems that terminate text lines with line feed characters only, the file may appear to be double spaced. 
The default value for this variable is 0 (off, false, no).  

For example, if you enter the following three lines in a TEXTAREA for a field called thetext:  
Sometext line 1  
Sometext line 2  
Sometext line 3  

The browser sends the following to the CGI program:  

thetext=Sometext+line+1%0D%0ASometext+line+2%0D%0ASometext+line+3%0D%0A  

If the CGI_STRIP_CR is set to 1 (on, true, yes), the runtime strips the carriage return characters so that the input line is the following:  

thetext=Sometext+line+1%0ASometext+line+2%0ASometext+line+3%0A  

HTML_TEMPLATE_PREFIX

This variable is used to specify a directory for locating HTML template files. 
It specifies one directory to be searched for the desired HTML template file. 
The current directory can be indicated by a period (regardless of the host operating system). This is the default.  

The following comments are owned by whomever posted them. This site is not responsible for what they say.