Ocamlnet 3 Reference Manual : Netcgi_apache.Apache.Request

# Module Netcgi_apache.Apache.Request

    module Request: sig .. end

    type t

Apache `request_rec` structure.

    val connection : t -> Netcgi_apache.Apache.Connection.t

`request_rec` `connection` field.

    val server : t -> Netcgi_apache.Apache.Server.t

`request_rec` `server` field.

    val next : t -> t

`request_rec` `next` field.
Raises `Not_found` if NULL.

    val prev : t -> t

`request_rec` `prev` field.
Raises `Not_found` if NULL.

    val main : t -> t

`request_rec` `main` field.
Raises `Not_found` if NULL.

    val the_request : t -> string

`request_rec` `the_request` field.
Raises `Not_found` if NULL.

    val assbackwards : t -> bool

`request_rec` `assbackwards` field; `true` if HTTP/0.9, "simple" request.

    val header_only : t -> bool

`request_rec` `header_only` field. It is `true` when the request method is HEAD.

    val protocol : t -> string

`request_rec` `protocol` field.
Raises `Not_found` if NULL.

    val proto_num : t -> int

`request_rec` `proto_num` field. Number version of protocol; 1.1 = 1001

    val hostname : t -> string

`request_rec` `hostname` field -- hostname to which the request was made.
Raises `Not_found` if NULL.

    val request_time : t -> float

`request_rec` `request_time` field.

    val status_line : t -> string

`request_rec` `status_line` field.
Raises `Not_found` if NULL.

    val set_status_line : t -> string -> unit

Set `request_rec` `status_line` field.

    val status : t -> int

`request_rec` `status` field.

    val set_status : t -> int -> unit

Set `request_rec` `status` field.

    val method_name : t -> string

`request_rec` `method` field.

    val method_number : t ->
           [ `CONNECT
           | `COPY
           | `DELETE
           | `GET
           | `INVALID
           | `LOCK
           | `MKCOL
           | `MOVE
           | `OPTIONS
           | `PATCH
           | `POST
           | `PROPFIND
           | `PROPPATCH
           | `PUT
           | `TRACE
           | `UNLOCK ]

`request_rec` `method_number` field (given symbolically instead of a number).

    val headers_in : t -> Netcgi_apache.Apache.Table.t

`request_rec` `headers_in` field.

    val headers_out : t -> Netcgi_apache.Apache.Table.t

`request_rec` `headers_out` field.

    val err_headers_out : t -> Netcgi_apache.Apache.Table.t

`request_rec` `err_headers_out` field.

    val subprocess_env : t -> Netcgi_apache.Apache.Table.t

`request_rec` `subprocess_env` field.

    val notes : t -> Netcgi_apache.Apache.Table.t

`request_rec` `notes` field.

    val content_type : t -> string

`request_rec` `content_type` field.
Raises `Not_found` if NULL.

    val set_content_type : t -> string -> unit

Set `request_rec` `content_type` field.

    val uri : t -> string

`request_rec` `uri` field.
Raises `Not_found` if NULL.

    val port : t -> int

Server port.

    val set_uri : t -> string -> unit

Set `request_rec` `uri` field.

    val filename : t -> string

`request_rec` `filename` field.
Raises `Not_found` if NULL.

    val set_filename : t -> string -> unit

Set `request_rec` `filename` field.

    val path_info : t -> string

`request_rec` `path_info` field.
Raises `Not_found` if NULL.

    val set_path_info : t -> string -> unit

Set `request_rec` `path_info` field.

    val args : t -> string

`request_rec` `args` field.
Raises `Not_found` if NULL.

    val set_args : t -> string -> unit

Set `request_rec` `args` field.

    val finfo : t -> Unix.stats option

`request_rec` `finfo` field.

    type read_policy =

`|` | `NO_BODY` | `(*` | Send 413 error if message has any body | `*)`
`|` | `CHUNKED_ERROR` | `(*` | Send 411 error if body without Content-Length | `*)`
`|` | `CHUNKED_DECHUNK` | `(*` | If chunked, remove the chunks for me. | `*)`
`|` | `CHUNKED_PASS` | `(*` | Pass the chunks to me without removal. | `*)`

Policy to apply by `setup_client_block` if the request message indicates a body.

    val setup_client_block : t ->
           read_policy -> unit

Setup for reading client request.
Raises `Netcgi_common.HTTP` in case of problems.

    val should_client_block : t -> bool

Returns true if there is any client request data.

    val get_client_block : t -> string

Get client request data.
Raises `Netcgi_common.HTTP` in case of reading error.

    val get_client_block_buf : t -> string -> int -> int -> int

`get_client_block_buf r buf ofs len` read a chunk of data and puts it in `buf.[ofs .. ofs+len-1]`. The return value `i` is the number of bytes actually read -- thus only `buf.[ofs .. ofs+i-1]` is meaningful.
Raises `Netcgi_common.HTTP` in case of reading error.

    val discard_request_body : t -> unit

Discard client request body.
Raises `Netcgi_common.HTTP` in case of problems.

    val user : t -> string

The authenticated user.
Raises `Not_found` if NULL.

    val auth_type : t -> string

    val note_auth_failure : t -> unit

Set headers to tell browser that authentication failed.

    val note_basic_auth_failure : t -> unit

Set headers to tell browser that basic authentication failed.

    val note_digest_auth_failure : t -> unit

Set headers to tell browser that digest authentication failed.

    val get_basic_auth_pw : t -> string option

Get the password sent in basic authentication.
Raises `Netcgi_common.HTTP` in case of problems.

    val internal_redirect : string -> t -> unit

Internally redirects immediately to `uri`.

    val internal_redirect_handler : string -> t -> unit

Internally redirects immediately to `uri` using handler specified by `r`.

    val send_http_header : t -> unit

Send the HTTP headers. Note that you must set the Status and Content-Type with `set_status` and `set_content_type` respectively.

    val rflush : t -> unit

Flush any buffered data waiting to be written to the client.
Raises `End_of_file` if it is not possible.

    val print_char : t -> char -> unit

Send a character back to the client.

    val print_string : t -> string -> unit

Send a string back to the client.

    val output : t -> string -> int -> int -> int

`output r s ofs len` send `s[ofs .. len-1]` back to the client. Returns the number of bytes actually written, which is smaller than the number of bytes in the string if there was a failure.

    val print_int : t -> int -> unit

Send a decimal number back to the client.

    val print_float : t -> float -> unit

Send a floating-point number back to the client.

    val print_newline : t -> unit

Send a CR LF back to the client.

    val print_endline : t -> string -> unit

Send a string followed by CR LF back to the client.

    val register_cleanup : t -> (unit -> unit) -> unit

Register a cleanup function which is called when the current request cycle ends.