Giter Club home page Giter Club logo

ocaml-clz's Introduction

Compression support for cohttp-lwt using decompress

CI Status

The library interface tries to stay somewhat close to dream-encoding.

Usage example:

let get_with_compression_support ?headers uri =
  let headers = Clz_cohttp.update_headers headers in
  let open Lwt.Syntax in
  let* resp, body = Cohttp_lwt_unix.Client.get ~headers uri in
  let status = Cohttp_lwt.Response.status resp in
  let* () = if status <> `OK then Cohttp_lwt.Body.drain_body body else Lwt.return_unit in
  match status with
  | `OK ->
    let body = Clz_cohttp.decompress (resp, body) in
    Lwt.return body
  | _ -> Lwt.fail_with "Not Ok"

It provides three libraries:

  • clz: functions to inflate and deflate strings, in case one does not need cohttp
  • clz.cfg: configuration for gzip deflate, separate only because it links unix
  • clz.cohttp: provides the module {!Clz_cohttp}, which contains helpers to add the necessary accept headers and to decompress the response bodies.

The documentation can be found on www.mseri.me/ocaml-clz/.

Why CLZ

The name was supposed to be temporary. Started as CUZ: Cohttp U gZip, but it really only supports cohttp-lwt, so it changed into CLS: Cohttp-Lwt-Zip, even if it supports both gzip and deflate. I use it in a lot of scripts now, more invasive changes would be way too time-consuming :P

ocaml-clz's People

Contributors

mseri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.