Skip to content

Commit

Permalink
Merge pull request #124 from inhabitedtype/lwt-unix
Browse files Browse the repository at this point in the history
rename httpaf-lwt package to httpaf-lwt-unix
  • Loading branch information
Spiros Eliopoulos authored Apr 22, 2019
2 parents a83518c + 7f42aab commit a1bc4b9
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ script: bash -ex ./.travis-docker.sh
env:
global:
- DISTRO="ubuntu"
- PINS="httpaf-async:. httpaf-lwt:. httpaf:."
- PINS="httpaf-async:. httpaf-lwt-unix:. httpaf:."
- PACKAGE="httpaf"
- TESTS=true
- POST_INSTALL_HOOK="opam install --with-test httpaf-async httpaf-lwt && opam exec -- make examples"
- POST_INSTALL_HOOK="opam install --with-test httpaf-async httpaf-lwt-unix && opam exec -- make examples"
matrix:
- OCAML_VERSION="4.07"
- OCAML_VERSION="4.06"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
(executable
(name wrk_lwt_benchmark)
(modules Wrk_lwt_benchmark)
(libraries httpaf httpaf_examples httpaf-lwt lwt.unix base))
(libraries httpaf httpaf_examples httpaf-lwt-unix lwt.unix base))

(alias
(name benchmarks)
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/wrk_lwt_benchmark.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open Base
open Httpaf_lwt
open Httpaf_lwt_unix
module Arg = Caml.Arg

let main port =
Expand Down
2 changes: 1 addition & 1 deletion examples/lwt/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(executables
(libraries httpaf httpaf-lwt httpaf_examples base stdio lwt lwt.unix)
(libraries httpaf httpaf-lwt-unix httpaf_examples base stdio lwt lwt.unix)
(names lwt_get lwt_post lwt_echo_post))

(alias
Expand Down
2 changes: 1 addition & 1 deletion examples/lwt/lwt_echo_post.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ open Base
open Lwt.Infix
module Arg = Caml.Arg

open Httpaf_lwt
open Httpaf_lwt_unix

let request_handler (_ : Unix.sockaddr) = Httpaf_examples.Server.echo_post
let error_handler (_ : Unix.sockaddr) = Httpaf_examples.Server.error_handler
Expand Down
2 changes: 1 addition & 1 deletion examples/lwt/lwt_get.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ open Lwt.Infix
module Arg = Caml.Arg

open Httpaf
open Httpaf_lwt
open Httpaf_lwt_unix

let error_handler _ = assert false

Expand Down
4 changes: 1 addition & 3 deletions examples/lwt/lwt_post.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ open Lwt.Infix
module Arg = Caml.Arg

open Httpaf
open Httpaf_lwt
open Httpaf_lwt_unix

let error_handler _ = assert false

Expand Down Expand Up @@ -49,6 +49,4 @@ let () =
]
ignore
"lwt_get.exe [-h HOST] [-p N]";

Lwt_main.run (main !port !host)
;;
5 changes: 4 additions & 1 deletion httpaf-lwt.opam → httpaf-lwt-unix.opam
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
opam-version: "2.0"
name: "httpaf-lwt"
maintainer: "Spiros Eliopoulos <[email protected]>"
authors: [ "Anton Bachin <[email protected]>" ]
authors: [
"Anton Bachin <[email protected]>"
"Spiros Eliopoulos <[email protected]>"
]
license: "BSD-3-clause"
homepage: "https://github.com/inhabitedtype/httpaf"
bug-reports: "https://github.com/inhabitedtype/httpaf/issues"
Expand Down
4 changes: 2 additions & 2 deletions lwt/dune → lwt-unix/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(library
(name httpaf_lwt)
(public_name httpaf-lwt)
(name httpaf_lwt_unix)
(public_name httpaf-lwt-unix)
(libraries faraday-lwt-unix httpaf lwt.unix)
(flags (:standard -safe-string)))
37 changes: 34 additions & 3 deletions lwt/httpaf_lwt.ml → lwt-unix/httpaf_lwt_unix.ml
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
open Lwt.Infix

(*----------------------------------------------------------------------------
Copyright (c) 2018 Inhabited Type LLC.
Copyright (c) 2018 Anton Bachin
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the author nor the names of his contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------------*)

open Lwt.Infix

(* Based on the Buffer module in httpaf_async.ml. *)
module Buffer : sig
type t

Expand Down
60 changes: 60 additions & 0 deletions lwt-unix/httpaf_lwt_unix.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
(*----------------------------------------------------------------------------
Copyright (c) 2018 Inhabited Type LLC.
Copyright (c) 2018 Anton Bachin
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the author nor the names of his contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------------*)

open Httpaf


(* The function that results from [create_connection_handler] should be passed
to [Lwt_io.establish_server_with_client_socket]. For an example, see
[examples/lwt_echo_server.ml]. *)
module Server : sig
val create_connection_handler
: ?config : Config.t
-> request_handler : (Unix.sockaddr -> Server_connection.request_handler)
-> error_handler : (Unix.sockaddr -> Server_connection.error_handler)
-> Unix.sockaddr
-> Lwt_unix.file_descr
-> unit Lwt.t
end

(* For an example, see [examples/lwt_get.ml]. *)
module Client : sig
val request
: ?config : Httpaf.Config.t
-> Lwt_unix.file_descr
-> Request.t
-> error_handler : Client_connection.error_handler
-> response_handler : Client_connection.response_handler
-> [`write] Httpaf.Body.t
end
26 changes: 0 additions & 26 deletions lwt/httpaf_lwt.mli

This file was deleted.

0 comments on commit a1bc4b9

Please sign in to comment.