All Projects → anmonteiro → Piaf

anmonteiro / Piaf

Licence: bsd-3-clause
Client library for HTTP/1.X / HTTP/2 written entirely in OCaml.

Programming Languages

ocaml
1615 projects

Projects that are alternatives of or similar to Piaf

restler
Restler is a beautiful and powerful Android app for quickly testing REST API anywhere and anytime.
Stars: ✭ 120 (+39.53%)
Mutual labels:  https, http2, http-client
Gun
HTTP/1.1, HTTP/2 and Websocket client for Erlang/OTP.
Stars: ✭ 710 (+725.58%)
Mutual labels:  http-client, http2, https
Isahc
The practical HTTP client that is fun to use.
Stars: ✭ 338 (+293.02%)
Mutual labels:  http-client, http2, https
Fast Android Networking
🚀 A Complete Fast Android Networking Library that also supports HTTP/2 🚀
Stars: ✭ 5,346 (+6116.28%)
Mutual labels:  http-client, http2, https
Jetty.project
Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
Stars: ✭ 3,260 (+3690.7%)
Mutual labels:  http-client, http2, https
Kurly
kurly is an alternative to the widely popular curl program, written in Golang.
Stars: ✭ 319 (+270.93%)
Mutual labels:  http-client, http2, https
Xmnetworking
A lightweight but powerful network library with simplified and expressive syntax based on AFNetworking.
Stars: ✭ 980 (+1039.53%)
Mutual labels:  http-client, http2, https
Blinksocks
A framework for building composable proxy protocol stack.
Stars: ✭ 587 (+582.56%)
Mutual labels:  http2, https
Phin
Node HTTP client
Stars: ✭ 449 (+422.09%)
Mutual labels:  http-client, https
Symfony Docker
A Docker-based installer and runtime for Symfony. Install: download and `docker-compose up`.
Stars: ✭ 732 (+751.16%)
Mutual labels:  http2, https
Golang Tls
Simple Golang HTTPS/TLS Examples
Stars: ✭ 857 (+896.51%)
Mutual labels:  http2, https
Http Client
Async HTTP/1.1+2 client for PHP based on Amp.
Stars: ✭ 553 (+543.02%)
Mutual labels:  http-client, https
Http
Event-driven, streaming HTTP client and server implementation for ReactPHP.
Stars: ✭ 507 (+489.53%)
Mutual labels:  http-client, https
Node Libcurl
libcurl bindings for Node.js
Stars: ✭ 447 (+419.77%)
Mutual labels:  http-client, http2
Cowboy
Small, fast, modern HTTP server for Erlang/OTP.
Stars: ✭ 6,533 (+7496.51%)
Mutual labels:  http2, https
Shgf
Simple HTTP golang framework
Stars: ✭ 13 (-84.88%)
Mutual labels:  http2, https
Farwest
Framework for building RESTful HATEOAS-driven applications.
Stars: ✭ 18 (-79.07%)
Mutual labels:  http2, https
Okurl
OkHttp Kotlin command line
Stars: ✭ 77 (-10.47%)
Mutual labels:  http2, https
Katwebx
An extremely fast static web server and reverse proxy for the modern web.
Stars: ✭ 39 (-54.65%)
Mutual labels:  http2, https
Esp Request
This project is no longer supported, please use
Stars: ✭ 65 (-24.42%)
Mutual labels:  http-client, https

piaf

Piaf is a client library for the HTTP/1.X and HTTP/2 protocols written entirely in OCaml.

Installation

Piaf is released to OPAM.

You can depend on it via esy or by running opam install piaf.

Note: make sure to mirror Piaf's own resolutions located in the opam file.

Usage & Examples

TODO, read the mli file for now.

Examples

open Piaf

let get_sync url =
  let open Lwt_result.Syntax in

  Lwt_main.run begin
    print_endline("Sending request...");

    let* response = Client.Oneshot.get (Uri.of_string url) in

    if (Status.is_successful response.status) then
      Body.to_string response.body
    else
      let message = Status.to_string response.status in
      Lwt.return (Error (`Msg message))
  end

let () =
  match get_sync "https://example.com" with
  | Ok body -> print_endline body
  | Error error ->
    let message = Error.to_string error in
    prerr_endline ("Error: " ^ message)

There's a more substantive example of using Piaf's API in bin/carl.ml, an implementation of a subset of curl, in caml.

Development

There's two ways to get a development environemnt up and running. If you have (or don't mind getting) nix installed, the repository includes scripts to set up a sandbox. Otherwise you can use opam to install the necessary dependencies globally.

Option 1) Setting up the sandbox

Assuming nix has been installed and set up, run nix-shell --pure in the repository root. Once it's done building, you should have the development environment set up!

Option 2) Setting up opam

For this approach you'll need to install opam and set it up with a switch using ocaml >= 4.08. Once that's done, run opam pin . --deps-only to install the dependencies.

Note that this installs the dependencies globally, and that the development environment is dependent on the switch used.

Building

Run dune build to build, dune build --watch to run a watcher daemon that will build incrementally.

Running examples

Run dune exec examples/docs/readme.exe to run the simple example above.

Run dune exec bin/carl.exe to run carl, the curl-like example.

License & Copyright

Copyright (c) 2019 António Nuno Monteiro

piaf is distributed under the 3-Clause BSD License, see LICENSE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].