class type http_call =object
..end
http_call
is the runtime container for HTTP method calls. It contains
the request message, the response message, and the current transmission
status.
In previous versions of netclient, this class type was called
message
. This was quite inexact because this class embraces both
messages that are part of a call.
Incompatible changes:
using_proxy
has been removed. This simply isn't a property of
an individual call.get_req_uri
has been removed from the public interface for similar
reasons.Netmime.mime_header
and Netmime.mime_body
objects. The old
style access methods remain in the API for now. The advantage is
that it is possible to use external files as body containers.`Base
and `Effective
.method is_served : bool
true
if request/response cycle(s) have been finished, i.e. the
call was successful, or a final error state has been reached.method status : status
method tls_session_props : Nettls_support.tls_session_props option
method request_method : string
method request_uri : string
method set_request_uri : string -> unit
Changed in Ocamlnet-3.3: The URI is no longer immediately parsed,
but first when the call is submitted to a pipeline. This means that
parsing errors will first be reported by the add
method. The
background is that parsing now depends on pipeline options.
method request_header : header_kind -> Netmime.mime_header
`Base
header. After the call has been processed,
the `Effective
header contains the version of the header that has
actually been transmitted.
The user should set the following headers:
Content-length
: Set this to the length of the request body
if known. (The client falls back to HTTP 1.0 if not set!)Content-type
: Set this to the media type of the request bodyExpect
: Set this to "100-continue" to enable a handshake before
the body is sent. Recommended for large bodies. (See also
set_expect_handshake
below.)Date
User-agent
Connection
method set_request_header : Netmime.mime_header -> unit
`Base
header objectmethod set_expect_handshake : unit -> unit
method set_chunked_request : unit -> unit
method effective_request_uri : string
method request_body : Netmime.mime_body
set_request_device
has been called (no body then).method set_request_body : Netmime.mime_body -> unit
method set_request_device : (unit -> Uq_io.in_device) -> unit
method set_accept_encoding : unit -> unit
Accept-Encoding
field in the request header, and
includes all decompression algorithms registered in
Netcompression
. Additionally, the automatic decompression of
the response body is enabled.
Note that you need to ensure that the algorithms are really
registered at Netcompression
. For example, to get gzip
support, run
Netgzip.init()
, and include netzip
as
library.
These methods will fail if the call has not yet been served!
If the call has been finished, but a hard error (e.g. socket error)
occurred, the
exception Http_protocol
is raised. When the server only
sent an error code, no exception is raised - but the user can
manually test for such codes (e.g. with repsonse_status
or
status
).
method response_status_code : int
method response_status_text : string
method response_status : Nethttp.http_status
`Ok
, `Multiple_choices
, `Bad_request
, and
`Internal_server_error
.method response_protocol : string
method response_header : Netmime.mime_header
Http_protocol
will be raised.method response_body : Netmime.mime_body
Http_protocol
will be raised. If the call has succeeded,
but no body has been transmitted, the empty body is substituted.
If the response is directly forwarded to a device (after
calling set_response_body_storage (`Device d)
), there is
no accessible response body, and this method will fail.
method response_body_storage : response_body_storage
`Memory
.method set_response_body_storage : response_body_storage -> unit
method max_response_body_length : int64
Int64.max_int
)method set_max_response_body_length : int64 -> unit
Response_too_large
.method get_reconnect_mode : http_call how_to_reconnect
Send_again_if_idem
.method set_reconnect_mode : http_call how_to_reconnect -> unit
method get_redirect_mode : http_call how_to_redirect
Redirect_if_idem
.method set_redirect_mode : http_call how_to_redirect -> unit
method proxy_enabled : bool
method set_proxy_enabled : bool -> unit
method no_proxy : unit -> unit
set_proxy_enabled false
method is_proxy_allowed : unit -> bool
proxy_enabled
These properties describe the HTTP method
method proxy_use_connect : bool
Http_client.https_cb_id
method empty_path_replacement : string
method is_idempotent : bool
method has_req_body : bool
method has_resp_body : bool
Channel bindings are used to distinguish between security requirements. There are normally only two types of requirements:
Http_client.http_cb_id
is used for messages that can only
be sent over HTTP connections, i.e. unencrypted TCP. It is automatically
set when the URL of the message starts with "http://".Http_client.https_cb_id
describes the requirement that the
message can only be sent over HTTPS connections, i.e. TLS-protected
TCP. It is automatically set when the URL of the message starts with
"https://".
The method channel_binding
is gone from this object type.
It is now available as part of pipeline
.
method set_channel_binding : channel_binding_id -> unit
set_request_uri
also sets
the channel binding, but always to the default for the type of URL.method same_call : unit -> http_call
`Unserved
These method were introduced in previous versions of netclient, but are quite limited. Some questionable methods are now deprecated and will be removed in future versions of netclient.
method get_req_method : unit -> string
request_method
.method get_host : unit -> string
Changed in Ocamlnet-3.3: The host can first be extracted after
the call is submitted to a pipeline.
method get_port : unit -> int
Changed in Ocamlnet-3.3: The port can first be extracted after
the call is submitted to a pipeline.
method get_path : unit -> string
Changed in Ocamlnet-3.3: The path can first be extracted after
the call is submitted to a pipeline.
method get_uri : unit -> string
request_uri
.method get_req_body : unit -> string
request_body # value
.method get_req_header : unit -> (string * string) list
In new code, the request_header
object should be accessed instead.
method assoc_req_header : string -> string
Not_found
method assoc_multi_req_header : string -> string list
method set_req_header : string -> string -> unit
method get_resp_header : unit -> (string * string) list
method assoc_resp_header : string -> string
method assoc_multi_resp_header : string -> string list
method get_resp_body : unit -> string
Otherwise, Http_error (code, body) is raised where 'code' is
the response code and 'body' is the body of the (errorneous)
response.
method dest_status : unit -> string * int * string
method private_api : private_api