Module B0_web.Http
HTTP requests.
HTTP requests via curl
.
HTTP methods and headers
type meth
=[
|
`CONNECT
|
`DELETE
|
`GET
|
`HEAD
|
`OPTIONS
|
`Other of string
|
`PATCH
|
`POST
|
`PUT
|
`TRACE
]
The type for HTTP methods.
val meth_to_string : meth -> string
meth_to_string m
is a string representation ofm
.
HTTP requests
val req : ?headers:headers -> ?body:string -> uri:string -> meth -> req
req uri m ~headers ~body
is a request onuri
with methodm
, headersheaders
(defaults to[]
) and bodybody
(defaults to""
).
val req_uri : req -> string
req_uri r
isr
's request URI.
val req_body : req -> string
req_body r
isr
's body.
HTTP responses
val resp_status : resp -> int
resp_status r
is the HTTP response status.
val resp_body : resp -> string
resp_body r
is the HTTP response body.
Performing requests
val curl : ?docs:string -> ?env:Cmdliner.Arg.env -> unit -> B0_std.Cmd.t Cmdliner.Term.t
curl
is a cli interface for specifying the curl command line tool.
val find_curl : ?search:B0_std.Fpath.t list -> curl:B0_std.Cmd.t -> unit -> (t, string) Stdlib.result
val perform : ?follow:bool -> t -> req -> (resp, string) Stdlib.result
perform curl r
performs requestr
viacurl
which is looked up in the PATH or in the environment variableB0_CURL
. Iffollow
istrue
(default) HTTP redirects for GET and HEAD requests that return 301, 302, 303, 305 or 307 are automatically followed.