# Module Ocsigen_http_client

    module Ocsigen_http_client: sig .. end

Using Ocsigen as a HTTP client

    val get : ?https:bool ->
           ?port:int -> host:string -> uri:string -> unit -> Ocsigen_http_frame.t Lwt.t

EXPERIMENTAL -- May evolve in the future. Do a GET HTTP request. The default port is 80 for HTTP, 443 for HTTPS. The default protocol is http (`https=false`).

    val raw_request : ?client:Ocsigen_extensions.client ->
           ?keep_alive:bool ->
           ?headers:Http_headers.t ->
           ?https:bool ->
           ?port:int ->
           content:string Ocsigen_stream.t option ->
           ?content_length:int64 ->
           http_method:Ocsigen_http_frame.Http_header.http_method ->
           host:string ->
           inet_addr:Unix.inet_addr ->
           uri:string -> unit -> unit -> Ocsigen_http_frame.t Lwt.t

Do an HTTP request (low level).

If the optional argument `headers` is present, no headers will be added by Ocsigen, but those in this argument and host, and `connection: close` or `connection: keep-alive`. Be carefull to respect HTTP/1.1 in this case!

The default port is 80 for HTTP, 443 for HTTPS.

The default protocol is http (`https=false`).

The optional parameter `~keep_alive` asks to keep the connection opened after the request for a short amount of time to allow other requests to the same server to use the same connection. It is true by default. If there is one opened free connection, we will use it instead of opening a new one.

If you do this request to serve it later to a client or to generate a page for a client, add the optional parameter `~client`. Thus, the request you do will be pipelined with other requests coming from the same connection. A request will never be pipelined after a request from another client connection. Pipelining will be used only for requests to server we know supporting it (according to previous requests). It is recommended to specify this optional parameter for all requests (with the value found in field `ri_client` of type `Ocsigen_extensions.request_info`).

The optional parameter `?head` asks to do a `HEAD` HTTP request. It is `false` by default.

When called without the last parameter, the function will pipeline the request (if needed), then return the function to get the page. This allows to keep pipeline order when writing an extension.

    val basic_raw_request : ?headers:Http_headers.t ->
           ?https:bool ->
           ?port:int ->
           content:string Ocsigen_stream.t option ->
           ?content_length:int64 ->
           http_method:Ocsigen_http_frame.Http_header.http_method ->
           host:string ->
           inet_addr:Unix.inet_addr -> uri:string -> unit -> Ocsigen_http_frame.t Lwt.t

Same as `Ocsigen_http_client.raw_request`, but does not try to reuse connections. Opens a new connections for each request. Much less efficient.