package quests

All checked builds pass
  1. Overview
  2. Docs
HTTP/1.1 client library like Python requests

Install

dune-project
 Dependency

Authors

Maintainers

Sources

0.1.3.tar.gz
md5=83070e5cd344642dd47cc993308d1dc3
sha512=9875953bf4cacd701b6af39af357b804007152cba6a069d62f200faf26b966674d601c45de9322415e2cd8f414233a40a5618ce6503750652b4d6f02b398579f

Description

Added to opam-repository:

README

Build

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

    • sessions/connection pooling
    • cookies
    • digest authentication
    • other compression schemes

Contributions welcome!

Dev Dependencies

None

Optional Dependencies

None

Used by (1)

  1. openstellina

Conflicts

None

Build status

Results of building quests with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.

Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.

Version OCaml 4.11 OCaml 4.14 OCaml 5.2 OCaml 5.4 OCaml 5.5
0.1.3 (this version) good good good good good
  • good Package successfully built
  • partial One of the dependencies failed to build
  • bad Package failed to build
  • n/a Package is not available in this environment
  • internal Internal failure