package quests
HTTP/1.1 client library like Python requests
Install
Dune Dependency
Authors
Maintainers
Sources
0.1.3.tar.gz
md5=83070e5cd344642dd47cc993308d1dc3
sha512=9875953bf4cacd701b6af39af357b804007152cba6a069d62f200faf26b966674d601c45de9322415e2cd8f414233a40a5618ce6503750652b4d6f02b398579f
README.md.html
README.md
Quests
Quests is an HTTP/1.1 client library using Cohttp. The API is closely inspired by Python's Requests. See documentation here.
Installation
Usage
open Lwt
let get () =
Quests.get "http://httpbin.org/get"
~params:[ ("key1", "value1"); ("key2", "value2") ]
>|= Quests.Response.show >|= print_endline
let post_form () =
Quests.post "http://httpbin.org/post" ~data:(Form [ ("key", "value") ])
>|= Quests.Response.show >|= print_endline
let post_json () =
Quests.post "http://httpbin.org/post" ~data:(Json [%yojson { key = "value" }])
>|= Quests.Response.show >|= print_endline
let gzip_response () =
Quests.get "http://httpbin.org/gzip"
>|= Quests.Response.show >|= print_endline
let following_redirects () =
Quests.get "http://httpbin.org/redirect/1"
>|= Quests.Response.show >|= print_endline
let basic_authentication () =
Quests.get "https://postman-echo.com/basic-auth" ~auth:(Basic ("username", "password"))
>|= Quests.Response.show >|= print_endline
let bearer_authentication () =
Quests.get "https://example.com/some-api" ~auth:(Bearer "a token")
>|= Quests.Response.show >|= print_endline
let sessions () =
let open Quests in
let s = Session.create () in
let%lwt () =
Session.get s "https://example.com" >|= Response.show >|= print_endline
in
Session.close s
let () =
Lwt_main.run
(Lwt_list.iter_s
(fun f -> f ())
[
get;
post_form;
post_json;
gzip_response;
following_redirects;
basic_authentication;
bearer_authentication;
sessions;
])
Features
Reuses connections to the same host
Automatically decompresses gzipped responses
Can follow redirects
Basic or bearer authentication
TODO
[x] - sessions/connection pooling
[ ] - cookies
[ ] - digest authentication
[ ] - other compression schemes
Contributions welcome!
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>