package hyper

  1. Overview
  2. Docs

Quick use

val get : ?headers:(string * string) list -> string -> string
val post : ?headers:(string * string) list -> string -> string -> string

Types

type request = client message
and response = server message
and handler = request -> response promise
and middleware = handler -> handler

Helpers

and 'a message = 'a Dream_pure.Message.message
and 'a promise = 'a Lwt.t
exception Response of response

Methods

type method_ = [
  1. | `GET
  2. | `POST
  3. | `PUT
  4. | `DELETE
  5. | `HEAD
  6. | `CONNECT
  7. | `OPTIONS
  8. | `TRACE
  9. | `PATCH
  10. | `Method of string
]
val method_to_string : [< method_ ] -> string
val string_to_method : string -> method_
val methods_equal : [< method_ ] -> [< method_ ] -> bool
val normalize_method : [< method_ ] -> method_

Status codes

type informational = [
  1. | `Continue
  2. | `Switching_Protocols
]
type successful = [
  1. | `OK
  2. | `Created
  3. | `Accepted
  4. | `Non_Authoritative_Information
  5. | `No_Content
  6. | `Reset_Content
  7. | `Partial_Content
]
type redirection = [
  1. | `Multiple_Choices
  2. | `Moved_Permanently
  3. | `Found
  4. | `See_Other
  5. | `Not_Modified
  6. | `Temporary_Redirect
  7. | `Permanent_Redirect
]
type client_error = [
  1. | `Bad_Request
  2. | `Unauthorized
  3. | `Payment_Required
  4. | `Forbidden
  5. | `Not_Found
  6. | `Method_Not_Allowed
  7. | `Not_Acceptable
  8. | `Proxy_Authentication_Required
  9. | `Request_Timeout
  10. | `Conflict
  11. | `Gone
  12. | `Length_Required
  13. | `Precondition_Failed
  14. | `Payload_Too_Large
  15. | `URI_Too_Long
  16. | `Unsupported_Media_Type
  17. | `Range_Not_Satisfiable
  18. | `Expectation_Failed
  19. | `Misdirected_Request
  20. | `Too_Early
  21. | `Upgrade_Required
  22. | `Precondition_Required
  23. | `Too_Many_Requests
  24. | `Request_Header_Fields_Too_Large
]
type server_error = [
  1. | `Internal_Server_Error
  2. | `Not_Implemented
  3. | `Bad_Gateway
  4. | `Service_Unavailable
  5. | `Gateway_Timeout
  6. | `HTTP_Version_Not_Supported
]
type status = [
  1. | standard_status
  2. | `Status of int
]
val status_to_string : [< status ] -> string
val status_to_reason : [< status ] -> string option
val status_to_int : [< status ] -> int
val int_to_status : int -> status
val is_informational : [< status ] -> bool
val is_successful : [< status ] -> bool
val is_redirection : [< status ] -> bool
val is_client_error : [< status ] -> bool
val is_server_error : [< status ] -> bool
val status_codes_equal : [< status ] -> [< status ] -> bool
val normalize_status : [< status ] -> status

Requests

val request : ?method_:[< method_ ] -> ?headers:(string * string) list -> ?body:string -> string -> request
val run : ?redirect_limit:int -> ?server:handler -> request -> response promise

Responses

val status : response -> status
val body : 'a message -> string promise

Headers

val header : 'a message -> string -> string option
val headers : 'a message -> string -> string list
val all_headers : 'a message -> (string * string) list
val has_header : 'a message -> string -> bool
val add_header : 'a message -> string -> string -> unit
val drop_header : 'a message -> string -> unit
val set_header : 'a message -> string -> string -> unit

Streams

val stream : ?method_:[< method_ ] -> ?headers:(string * string) list -> ?close:bool -> string -> (stream -> unit promise) -> request
val body_stream : response -> stream
val read : stream -> string option promise
val write : stream -> string -> unit promise
val flush : stream -> unit promise
val close : stream -> unit promise

WebSockets

type websocket
val websocket : ?headers:(string * string) list -> ?redirect_limit:int -> ?server:handler -> string -> (websocket, response) Stdlib.result promise
type text_or_binary = [
  1. | `Text
  2. | `Binary
]
type end_of_message = [
  1. | `End_of_message
  2. | `Continues
]
val send : ?text_or_binary:[< text_or_binary ] -> ?end_of_message:[< end_of_message ] -> websocket -> string -> unit promise
val receive : websocket -> string option promise
val receive_fragment : websocket -> (string * text_or_binary * end_of_message) option promise
val close_websocket : ?code:int -> websocket -> unit promise

Web formats

val to_form_urlencoded : (string * string) list -> string
OCaml

Innovation. Community. Security.