Module Http


module Http: sig .. end

HTTP connections




type error =
| Socket
| Response
| UrlDecoding
Error handling
exception Error of error
val string_of_error : error -> string
type connection = file_descr 
A connection with an http server.
val user_agent : string
User-agent for liquidsoap
val url_decode : ?plus:bool -> string -> string
Decode an url.
val url_encode : ?plus:bool -> string -> string
Encode an url.
val url_split_host_port : string -> string * int option * string
Split an URL to return host, port and URI.
val http_sanitize : string -> string
http_sanitize url encodes the relevant parts of a url (path and arguments, without their seperators).
val is_url : string -> bool
Basic detection of whether a path is an HTTP url.
val dirname : string -> string
Url without the trailing filename.
val args_split : string -> (string, string) Hashtbl.t
split arg=value&arg2=value2 into (arg, value) Hashtbl.t
val connect : ?bind_address:string -> string -> int -> connection
Connect to an http server given an host and a port.
val disconnect : connection -> unit
Disconnect from an http server.
type status = string * int * string 
Status of a request: version of the HTTP protocol, status number and status message.
type headers = (string * string) list 
Type for headers data.
val read_crlf : ?log:(string -> unit) ->
?max:int -> timeout:float -> connection -> string
val request : ?log:(string -> unit) ->
timeout:float ->
connection -> string -> (string * int * string) * (string * string) list
val get : ?headers:(string * string) list ->
?log:(string -> unit) ->
timeout:float ->
connection ->
string -> int -> string -> (string * int * string) * (string * string) list
get ?log ?headers ~timeout socket host port file makes a GET request. Returns the status and the headers.
val post : ?headers:(string * string) list ->
?log:(string -> unit) ->
timeout:float ->
string ->
connection ->
string -> int -> string -> (string * int * string) * (string * string) list
post ?log ?headers ~timeout data socket host port file makes a POST request. Returns the status and the headers.
val read : ?log:(string -> unit) ->
timeout:float -> connection -> int option -> string
read ?log ~timeout len reads len bytes of data or all available data if len is None.

type request =
| Get
| Post of string
Type for full Http request.
val full_request : ?headers:(string * string) list ->
?port:int ->
?log:(string -> unit) ->
timeout:float ->
host:string ->
url:string ->
request:request ->
unit -> (string * int * string) * (string * string) list * string
Perform a full Http request and return the response status,headers and data.