From 7320f875d14c5aaa08cb6930308e5972012780bc Mon Sep 17 00:00:00 2001 From: Anton Bachin Date: Fri, 11 Feb 2022 13:50:24 +0300 Subject: [PATCH] Rename ~https to ~tls --- docs/web/postprocess/index.ml | 8 ++++---- example/8-debug/README.md | 2 +- src/dream.ml | 2 +- src/dream.mli | 18 +++++++++--------- src/http/http.ml | 22 +++++++++++----------- src/server/cookie.ml | 4 ++-- src/server/helpers.ml | 16 ++++++++-------- src/server/origin_referrer_check.ml | 4 ++-- 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/docs/web/postprocess/index.ml b/docs/web/postprocess/index.ml index ecde3db0..f028d57f 100644 --- a/docs/web/postprocess/index.ml +++ b/docs/web/postprocess/index.ml @@ -1454,7 +1454,7 @@ let new_global_replacement = {| let run_expected = {|
val run : ?interface:string -> ?port:int -> ?stop:unit promise -> ?error_handler:error_handler -> -?https:bool -> ?certificate_file:string -> ?key_file:string -> ?builtins:bool -> +?tls:bool -> ?certificate_file:string -> ?key_file:string -> ?builtins:bool -> ?greeting:bool -> ?adjust_terminal:bool -> handler -> unit
|} @@ -1468,7 +1468,7 @@ let run_replacement = {| ?secret:string -> ?old_secrets:string list -> ?prefix:string -> - ?https:true -> + ?tls:bool -> ?certificate_file:string -> ?key_file:string -> ?builtins:bool -> @@ -1479,7 +1479,7 @@ let run_replacement = {| let serve_expected = {|
val serve : ?interface:string -> ?port:int -> ?stop:unit promise -> ?error_handler:error_handler -> -?https:bool -> ?certificate_file:string -> ?key_file:string -> ?builtins:bool -> +?tls:bool -> ?certificate_file:string -> ?key_file:string -> ?builtins:bool -> handler -> unit promise
|} @@ -1493,7 +1493,7 @@ let serve_replacement = {| ?secret:string -> ?old_secrets:string list -> ?prefix:string -> - ?https:bool -> + ?tls:bool -> ?certificate_file:string -> ?key_string:string -> ?builtins:bool -> diff --git a/example/8-debug/README.md b/example/8-debug/README.md index be3a4058..682600ce 100644 --- a/example/8-debug/README.md +++ b/example/8-debug/README.md @@ -63,7 +63,7 @@ Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.9,ru-RU;q=0.8,ru;q=0.7 dream.client: 127.0.0.1:64687 -dream.https: false +dream.tls: false dream.request_id: 3 dream.params: ``` diff --git a/src/dream.ml b/src/dream.ml index 19faaba2..3e3db2ce 100644 --- a/src/dream.ml +++ b/src/dream.ml @@ -96,7 +96,7 @@ include Status (* Requests *) let client = Helpers.client -let https = Helpers.https +let tls = Helpers.tls let method_ = Message.method_ let target = Message.target let prefix = Router.prefix diff --git a/src/dream.mli b/src/dream.mli index a231ba1e..faee2600 100644 --- a/src/dream.mli +++ b/src/dream.mli @@ -360,8 +360,8 @@ val normalize_status : [< status ] -> status val client : request -> string (** Client sending the request. For example, ["127.0.0.1:56001"]. *) -val https : request -> bool -(** Whether the request was sent over HTTPS. *) +val tls : request -> bool +(** Whether the request was sent over a TLS connection. *) val method_ : request -> method_ (** Request method. For example, [`GET]. *) @@ -651,7 +651,7 @@ val set_cookie : {{:https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Path_attribute} MDN}. - [~secure] sets the [Secure] attribute. By default, [Secure] is set if - {!Dream.https} is [true] for the {!type-request}. See + {!Dream.tls} is [true] for the {!type-request}. See {{:https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-07#section-4.1.2.5} RFC 6265bis ยง4.1.2.5} and {{:https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies} @@ -2208,7 +2208,7 @@ val run : ?port:int -> ?stop:unit promise -> ?error_handler:error_handler -> - ?https:bool -> + ?tls:bool -> ?certificate_file:string -> ?key_file:string -> ?builtins:bool -> @@ -2238,8 +2238,8 @@ val run : low-level errors. See {!section-errors} and example {{:https://github.com/aantron/dream/tree/master/example/9-error#files} [9-error]} \[{{:http://dream.as/9-error} playground}\]. - - [~https:true] enables HTTPS. You should also specify [~certificate_file] - and [~key_file]. However, for development, Dream includes an insecure + - [~tls:true] enables TLS. You should also specify [~certificate_file] and + [~key_file]. However, for development, Dream includes an insecure compiled-in {{:https://github.com/aantron/dream/tree/master/src/certificate#files} localhost certificate}. Enabling HTTPS also enables transparent upgrading @@ -2247,9 +2247,9 @@ val run : {{:https://github.com/aantron/dream/tree/master/example/l-https#files} [l-https]}. - [~certificate_file] and [~key_file] specify the certificate and key file, - respectively, when using [~https]. They are not required for development, + respectively, when using [~tls]. They are not required for development, but are required for production. Dream will write a warning to the log if - you are using [~https], don't provide [~certificate_file] and [~key_file], + you are using [~tls], don't provide [~certificate_file] and [~key_file], and [~interface] is not ["localhost"]. - [~builtins:false] disables {!section-builtin}. @@ -2267,7 +2267,7 @@ val serve : ?port:int -> ?stop:unit promise -> ?error_handler:error_handler -> - ?https:bool -> + ?tls:bool -> ?certificate_file:string -> ?key_file:string -> ?builtins:bool -> diff --git a/src/http/http.ml b/src/http/http.ml index 6b91da3a..def04770 100644 --- a/src/http/http.ml +++ b/src/http/http.ml @@ -52,7 +52,7 @@ let websocket_log = chance to tell the user that something is wrong with their app. *) (* TODO Rename conn like in the body branch. *) let wrap_handler - https + tls (user's_error_handler : Catch.error_handler) (user's_dream_handler : Message.handler) = @@ -96,7 +96,7 @@ let wrap_handler Stream.stream body Stream.no_writer in let request : Message.request = - Helpers.request ~client ~method_ ~target ~https ~version ~headers body in + Helpers.request ~client ~method_ ~target ~tls ~version ~headers body in (* Call the user's handler. If it raises an exception or returns a promise that rejects with an exception, pass the exception up to Httpaf. This @@ -188,7 +188,7 @@ let wrap_handler (* TODO Factor out what is in common between the http/af and h2 handlers. *) let wrap_handler_h2 - https + tls (_user's_error_handler : Catch.error_handler) (user's_dream_handler : Message.handler) = @@ -226,7 +226,7 @@ let wrap_handler_h2 Stream.stream body Stream.no_writer in let request : Message.request = - Helpers.request ~client ~method_ ~target ~https ~version ~headers body in + Helpers.request ~client ~method_ ~target ~tls ~version ~headers body in (* Call the user's handler. If it raises an exception or returns a promise that rejects with an exception, pass the exception up to Httpaf. This @@ -483,7 +483,7 @@ let serve_with_maybe_https ~port ~stop ~error_handler - ~https + ~tls ?certificate_file ?key_file ?certificate_string ?key_string ~builtins @@ -500,7 +500,7 @@ let serve_with_maybe_https end; *) (* TODO Make sure there is a similar check in cipher.ml now.Hpack *) - match https with + match tls with | `No -> serve_with_details caller_function_for_error_messages @@ -632,7 +632,7 @@ let serve ?(port = default_port) ?(stop = never) ?(error_handler = Error_handler.default) - ?(https = false) + ?(tls = false) ?certificate_file ?key_file ?(builtins = true) @@ -644,7 +644,7 @@ let serve ~port ~stop ~error_handler - ~https:(if https then `OpenSSL else `No) + ~tls:(if tls then `OpenSSL else `No) ?certificate_file ?key_file ?certificate_string:None @@ -659,7 +659,7 @@ let run ?(port = default_port) ?(stop = never) ?(error_handler = Error_handler.default) - ?(https = false) + ?(tls = false) ?certificate_file ?key_file ?(builtins = true) @@ -713,7 +713,7 @@ let run if greeting then begin let scheme = - if https then + if tls then "https" else "http" @@ -736,7 +736,7 @@ let run ~port ~stop ~error_handler - ~https:(if https then `OpenSSL else `No) + ~tls:(if tls then `OpenSSL else `No) ?certificate_file ?key_file ?certificate_string:None ?key_string:None ~builtins diff --git a/src/server/cookie.ml b/src/server/cookie.ml index 8ea7493e..31a34f05 100644 --- a/src/server/cookie.ml +++ b/src/server/cookie.ml @@ -56,7 +56,7 @@ let cookie let secure = match secure with | Some secure -> secure - | None -> Helpers.https request + | None -> Helpers.tls request in let cookie_prefix = infer_cookie_prefix cookie_prefix domain path secure in @@ -100,7 +100,7 @@ let set_cookie let secure = match secure with | Some secure -> secure - | None -> Helpers.https request + | None -> Helpers.tls request in let cookie_prefix = infer_cookie_prefix cookie_prefix domain path secure in diff --git a/src/server/helpers.ml b/src/server/helpers.ml index b327580f..e3d339f6 100644 --- a/src/server/helpers.ml +++ b/src/server/helpers.ml @@ -30,28 +30,28 @@ let set_client request client = -let https_field = +let tls_field = Message.new_field - ~name:"dream.https" + ~name:"dream.tls" ~show_value:string_of_bool () -let https request = - match Message.field request https_field with +let tls request = + match Message.field request tls_field with | Some true -> true | _ -> false -let set_https request https = - Message.set_field request https_field https +let set_tls request tls = + Message.set_field request tls_field tls -let request ~client ~method_ ~target ~https ~version ~headers server_stream = +let request ~client ~method_ ~target ~tls ~version ~headers server_stream = let request = Message.request ~method_ ~target ~version ~headers Stream.null server_stream in set_client request client; - set_https request https; + set_tls request tls; request let request_with_body ?method_ ?target ?version ?headers body = diff --git a/src/server/origin_referrer_check.ml b/src/server/origin_referrer_check.ml index beb9fd55..f5177720 100644 --- a/src/server/origin_referrer_check.ml +++ b/src/server/origin_referrer_check.ml @@ -49,8 +49,8 @@ let origin_referrer_check inner_handler request = let schemes_match = match Uri.scheme origin_uri with - | Some "http" -> not (Helpers.https request) - | Some "https" -> Helpers.https request + | Some "http" -> not (Helpers.tls request) + | Some "https" -> Helpers.tls request | _ -> false in