Skip to content
This repository
tag: v1815
Fetching contributors…

Cannot retrieve contributors at this time

file 142 lines (104 sloc) 5.502 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
(** HttpTools:

Just some support routines for handling HTTP requests and responses.

*)

val http : NetAddr.protocol

(** Possible exceptions *)

exception CallbackAbort

(** Timing functions. *)

val rpt : int -> ('a -> 'b) -> 'a -> unit
val timefn : int -> ('a -> 'b) -> 'a -> unit
val verifyfn : ('a -> 'b) -> ('a -> string) -> ('b -> string) -> ('a * 'b) list -> bool

(** Basic string functions *)

val strcom : string -> int -> string * string option
val rmldtrsp0 : string -> int -> string
val rmldtrsp : string -> string
val rmldtrsp2 : string * string -> string * string
val rmldtrspl : string list -> string list

(** String based support for raw parser *)

val pos_mark : ('a -> int -> 'b) -> 'a -> int -> 'a -> int -> int -> (int * int) option
val upto_mark : string -> int -> string -> int -> int -> int * int * string
val upto_mark_ci : string -> int -> string -> int -> int -> int * int * string

(** Streaming parsers *)

val buf_clean : (Buffer.t * int ref) -> unit

val upto_mark_stream : ('a -> char) -> 'a -> string -> string

val get_char_cps : ('a -> ('b * string -> 'c) -> 'c) -> string ref * int ref * 'a -> (char -> 'c) -> 'c

val upto_mark_stream_cps : ?inclusive:bool -> Buffer.t -> ('a -> (char -> 'b) -> 'b) -> 'a -> string -> (string -> 'b) -> 'b
val upto_mark_stream_cps2 :
  ?inclusive:bool -> (*?oc_opt:out_channel option ->*) Scheduler.t -> Scheduler.connection_info -> (Buffer.t * int ref) -> string ->
  ?callback:('a -> int -> Buffer.t -> bool) -> 'a -> ?blocksize:int ->
  ?err_cont:(exn -> unit) -> ?timeout:Time.t -> (Buffer.t * int * int -> unit) -> unit
val upto_mark_stream_cps3 :
  ?inclusive:bool -> (*?oc_opt:out_channel option ->*) Scheduler.t -> Scheduler.connection_info -> (Buffer.t * int ref) -> string ->
  ?callback:('a -> int -> Buffer.t -> bool) -> 'a -> ?blocksize:int ->
  ?err_cont:(exn -> unit) -> ?timeout:Time.t -> (string -> unit) -> unit

val upto_stream_cps :
  ?inclusive:bool ->
  Buffer.t ->
  ('a -> ('b * string -> 'c) -> 'c) ->
  string ref * int ref * 'a -> string -> (string -> 'c) -> 'c

val read_upto_stream_cps :
  ?inclusive:bool ->
  Buffer.t ->
  string ref * int ref * Scheduler.connection_info ->
  string ->
  Scheduler.t ->
  ?err_cont:(exn -> unit) -> ?timeout:Time.t -> (string -> unit) -> unit

val fixed_stream_cps :
  Buffer.t ->
  ('a -> ('b * string -> 'c) -> 'c) ->
  string ref * int ref * 'a -> int -> (string -> 'c) -> 'c

val read_fixed_stream_cps :
  Buffer.t ->
  string ref * int ref * Scheduler.connection_info ->
  int ->
  Scheduler.t ->
  ?err_cont:(exn -> unit) -> ?timeout:Time.t -> (string -> unit) -> unit

val fixed_stream_cps2_buf :
  (*?oc_opt:out_channel option ->*) Scheduler.t -> Scheduler.connection_info -> (Buf.t * int ref) -> int ->
  ?callback:('a -> int -> Buf.t -> bool) -> 'a -> ?blocksize:int ->
  ?err_cont:(exn -> unit) -> ?timeout:Time.t -> (Buf.t * int * int -> unit) -> unit
val fixed_stream_cps2 :
  (*?oc_opt:out_channel option ->*) Scheduler.t -> Scheduler.connection_info -> (Buffer.t * int ref) -> int ->
  ?callback:('a -> int -> Buffer.t -> bool) -> 'a -> ?blocksize:int ->
  ?err_cont:(exn -> unit) -> ?timeout:Time.t -> (Buffer.t * int * int -> unit) -> unit
val fixed_stream_cps3 :
  (*?oc_opt:out_channel option ->*) Scheduler.t -> Scheduler.connection_info -> (Buffer.t * int ref) -> int ->
  ?callback:('a -> int -> Buffer.t -> bool) -> 'a -> ?blocksize:int ->
  ?err_cont:(exn -> unit) -> ?timeout:Time.t -> (string -> unit) -> unit

val upto : string -> ('a -> ('b * string -> 'c) -> 'c) -> string ref * int ref * 'a -> (string -> 'c) -> 'c

(** putback string onto protocol input *)

val putback : string -> string ref * int ref * 'a -> unit
val putback2 : string -> Buffer.t * int ref -> unit

(** Fast-forward functions *)

val skip_sptab : string -> int -> int -> int
val skip_lws : string -> int -> int -> int

(** More streaming functions *)

val upto_mark_lws : string -> int -> string -> int -> int -> int * int * string
val upto_mark_lws_ci : string -> int -> string -> int -> int -> int * int * string

(** Overflow from rcontent *)

(** content_compress gzip deflate compression_level cache_response content content_len:
Compress file content according to gzip/deflate flags (deflate has priority).
Does not read file in if file content, writes from/to disc.
*)
val content_compress : Scheduler.t -> bool -> bool -> int -> bool -> Rcontent.content -> int ->
  ((bool * Rcontent.content) -> unit) -> unit

(** Simple buffer management *)

val collect_bufs : int -> unit
val get_buf : ?hint:int -> unit -> Buffer.t
val free_buf : Buffer.t -> unit

(** SSL certificate generation *)

val make_ssl_cert : string -> string -> string -> SslAS.ssl_certificate option
val make_ssl_verify : string -> string -> string -> string -> (Ssl.certificate -> bool) -> bool -> SslAS.ssl_verify_params option
Something went wrong with that request. Please try again.