package hyper

  1. Overview
  2. Docs

Module HyperSource

Quick use

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

Types

Sourcetype request = client message
Sourceand response = server message
Sourceand handler = request -> response promise
Sourceand middleware = handler -> handler

Helpers

Sourceand 'a promise = 'a Lwt.t
Sourceexception Response of response

Methods

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

Status codes

Sourcetype informational = [
  1. | `Continue
  2. | `Switching_Protocols
]
Sourcetype successful = [
  1. | `OK
  2. | `Created
  3. | `Accepted
  4. | `Non_Authoritative_Information
  5. | `No_Content
  6. | `Reset_Content
  7. | `Partial_Content
]
Sourcetype redirection = [
  1. | `Multiple_Choices
  2. | `Moved_Permanently
  3. | `Found
  4. | `See_Other
  5. | `Not_Modified
  6. | `Temporary_Redirect
  7. | `Permanent_Redirect
]
Sourcetype 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
]
Sourcetype server_error = [
  1. | `Internal_Server_Error
  2. | `Not_Implemented
  3. | `Bad_Gateway
  4. | `Service_Unavailable
  5. | `Gateway_Timeout
  6. | `HTTP_Version_Not_Supported
]
Sourcetype status = [
  1. | standard_status
  2. | `Status of int
]
Sourceval status_to_string : [< status ] -> string
Sourceval status_to_reason : [< status ] -> string option
Sourceval status_to_int : [< status ] -> int
Sourceval int_to_status : int -> status
Sourceval is_informational : [< status ] -> bool
Sourceval is_successful : [< status ] -> bool
Sourceval is_redirection : [< status ] -> bool
Sourceval is_client_error : [< status ] -> bool
Sourceval is_server_error : [< status ] -> bool
Sourceval status_codes_equal : [< status ] -> [< status ] -> bool
Sourceval normalize_status : [< status ] -> status

Requests

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

Responses

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

Headers

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

Streams

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

WebSockets

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

Web formats

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

Innovation. Community. Security.