Git Product home page Git Product logo

ocaml-http's Introduction

OCaml HTTP

do it yourself (OCaml) HTTP daemon

OCaml HTTP is an OCaml library freely inspired from Perl's HTTP::Daemon module that permits you to write simple HTTP daemons in OCaml.

The main API let you define a HTTP daemon specification, which contains, among other parameters, a callback function that is invoked each time a request is received. The callback function will be invoked with an instance of an object representing the received HTTP request and an out_channel connected to the remote HTTP client socket.

Then you can start your HTTP daemon invoking the main function passing your specification. Each time a client connect to the TCP port bound by your daemon, OCaml HTTP will parse the request and instantiate the request object. If all goes well your callback will be invoked, otherwise appropriate error messages will be sent back to the client without disturbing your callback.

You can use a lot of facility functions in your callback that permits you to send easily headers, error responses, file, or abstract HTTP response objects. Otherwise you can also choose the 'hard way' and send data directly to the out_channel (expecially useful for sending data incrementally to the client). You can also mix the two approaches.

Daemon specifications are used also to specify other parameters governing daemon behaviour like: TCP port and address to bind, way of handling incoming requests (handle all of them in a single process, fork a new process or spawn a new thread for each incoming request), timeout, authentication requirements (username and password for HTTP basic authentication).

OCaml HTTP contains also a tiny implementation of a HTTP client which can be used to retrieve resources via GET HTTP method and to iter on them (useful for huge resources which can't be kept in memory).

OCaml HTTP is freely distributed under the GNU Library General Public License (GPL) and is available here for download:

official Debian packages are available: libhttp-ocaml-dev

To build OCaml HTTP from sources you will need:

  • the OCaml compiler
  • findlib
  • ocamlnet
  • pcre-ocaml

ocaml-http's People

Contributors

sacerdot avatar jonathanderque avatar

Watchers

Stefano Zacchiroli avatar James Cloos 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.