Http v1.0.0 documentation

Documentation generated by XL CLAIRE v3.3.37 at Fri, 17 Nov 2006

Category index

  1. Http filters
    1. Chunked transfer coding
    2. Content length spy
    3. Boundary reader
    4. HTML special char convertion
  2. Request input processing
    1. Maximun POST size
    2. Simple form variables
    3. Multivalued form variables
    4. Uploads

Table index

Class index

Method index


Http categories


categories
Http filters
Chunked transfer coding
Content length spy

Http filters

Chunked transfer coding

chunker implement the RFC2616 (sec 3.6.1) "Chunked transfer coding" used to define the body-length of a message. Unlike content-length, chunked coding allow stream oriented message generation (i.e. a message which has an undefined length at the time it is generated).


Chunked transfer coding categories
Http filters
Content length spy
Boundary reader

Content length spy


Content length spy categories
Http filters
Boundary reader
HTML special char convertion

Boundary reader


Boundary reader categories
Http filters
HTML special char convertion
Request input processing
Maximun POST size

HTML special char convertion


Http filters
HTML special char convertion
categories
Request input processing
Maximun POST size
Simple form variables

Request input processing

Maximun POST size

As a security concern, we may define the environment variable WCL_MAX_POST that specifies a maximun size in mega-octet for POST data. When this variable is specified the request input processor checks that the length of the input message is lesser than the specified maximun POST size and raise an error otherwise.


Maximun POST size categories
Request input processing
Simple form variables
Multivalued form variables

Simple form variables

The HTTP handler is able to read a request input which is either of content type multipart/form-data or application/x-www-form-urlencoded. These protocols are use by the client to send form variables. Form variables are usualy defined with a name and a value. When reading the input of a request the HTTP handler fills a table that associates a form variable names to its value both represented as string. Let's consider the following form :

 ?><form>
         <input type=text name='name'>
         <input type=submit>
 </form>
<?
 
When this form is submited by the client a new entry is added in the $ table with the key field_name and the value string that was entered by the client in the text input, such we can use :

 $["name"]
 
Notice that the $ table defaults to false such we can test the existence of a form variable with :

 if $["name"]
     ...
 
Also notice that a form field that is left empty is usualy not part of the submited request.

If the same variable name is used for multiple form variable then the entry in the $ table will be set to the last occurrence found during the request input processing.


Simple form variables categories
Request input processing
Multivalued form variables
Uploads

Multivalued form variables

To handle multiple values for a given variable name one should use the bracket notation as follow :

 ?><form>
         <input type=text name='name[key1]' value='val1'>
         <input type=text name='name[key2]' value='val2'>
         <input type=text name='name[]' value='val3'>
         <input type=submit>
 </form>
<?
 
If the above form is submited as is (i.e. specified defulat values are left unchenged by the client) we would find entries in the $, $keys and, $value tables :

 $["name"=> list("val1""val2""val3")
 $keys["name"=> list("key1""key2")
 $value["name""key1"=> "val1"
 $value["name""key2"=> "val2"
 
Notice that when we use the bracket notation for a variable name, $ is filled with all values found for that name and if the key enclosed by the brackets isn't empty then the $keys and $value would also be updated. $keys contains all found keys for a given name and $value contain the value for a given name/key pair.


Multivalued form variables categories
Request input processing
Uploads

Uploads

Last, the input processor is able to read multipart/form-data encoded forms which may be used to make a form with an input of type file :

 ?><form method=POST enctype="multipart/form-data">
     <input type=file name="file">
     <input type=submit>
 </form>
<?
 
When such a form is submited, the request input processor create a new entry in the $ table (as for simple form variables) of the upload type. An upload correspond to a file, that would be been saved by the server on the hard disk at the file_path attribute of the upload :

 if $["file"]
     let f := fopen($["file"].file_path"r")
     in ...
 
The directory where file are uploaded is taken from the environment variable WCL_UPLOAD_FOLDER.


Http tables


categories Simple form variables Http table

$[vname:string] : any := false

$ is filled by the request input processor with all values found for a given variable name.


categories Multivalued form variables Http table

$keys[vname:string] : any := false

The $keys table is filled by the input processor with the list of keys found for a given variable name.


categories Multivalued form variables Http table

$value[vname:string, key:string] : any := false

The $value table is filled by the input processor the value of the the given variable name and key pair.


Http classes


categories Uploads ephemeral Http class

upload <: ephemeral_object

An upload object is created for a form input when it is of type file. original_name/original_path would contain the name/path of the file from the client-side point of view, content_type would contain the MIME type od the uploaded file (e.g. "text/plain"), file_size is the size of the file in bytes. file_folder is the path of the server-side directory where the server uploaded the file (It is taken as the value of the environment variable WCL_UPLOAD_FOLDER) and file_path is the server-side path of the uploaded file.


Http methods


categories Boundary reader normal dispatch Http method

Http/boundary_reader!(self:port, bound:string) -> boundary_reader

boundary_reader implements a subset of RFC2046.


categories Chunked transfer coding normal dispatch Http method

Http/chunker!(self:port) -> chunker

chunker!(self) creates a read/write filter that handle chunked encoded datas.


categories Content length spy normal dispatch Http method

Http/content_length_spy!(self:port) -> content_length_spy

content_length_spy!(self) is equivalent to content_length_spy!(self, integer!(getenv("CONTENT_LENGTH"))). The CONTENT_LENGTH environment variable is usualy sets in a CGI environment.


categories Content length spy normal dispatch Http method

Http/content_length_spy!(self:port, n:integer) -> content_length_spy

The content length spy is used to force an EOF condition after content_length bytes which prevent blocking read to occur past the message body.


categories HTML special char convertion normal dispatch Http method

Http/html_special_char_converter!(self:port) -> html_special_char_converter

html_special_char_converter!(self) is equivalent to html_special_char_converter!(self, true).


categories HTML special char convertion normal dispatch Http method

Http/html_special_char_converter!(self:port, convert_slash_n_and_space?:boolean) -> html_special_char_converter

html_special_char_converter!(self, convert_slash_n_and_space?) creates a new converter. A convertion is applied on each following chars :

When convert_slash_n_and_space? is true spaces and line feeds are also converted as follow : Notice that in the later case the \n is kept, this makes HTML outputs much more readable.


categories Boundary reader normal dispatch Http method

Http/last_boundary?(self:boundary_reader) -> boolean

last_boundary?(self) checks the last end of file condition also correspond to the last boundary i.e. all bounded block have been read.


categories Boundary reader normal dispatch Http method

Http/reach_boundary(self:boundary_reader) -> void

reach_boundary(self) reset the end of file condition such we are ready to read a new bounded block.