aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPéter Dimitrov <[email protected]>2019-04-18 14:51:50 +0200
committerPéter Dimitrov <[email protected]>2019-04-18 14:51:50 +0200
commit94254dfffa9cb4b53a95873e1fbbbce4ce7049ce (patch)
treefc4e264ef457c503cd9ea152301ca84a962122d1
parentde9126d6cb258bb6c0ed085e2c7d95a5a54482a7 (diff)
downloadotp-94254dfffa9cb4b53a95873e1fbbbce4ce7049ce.tar.gz
otp-94254dfffa9cb4b53a95873e1fbbbce4ce7049ce.tar.bz2
otp-94254dfffa9cb4b53a95873e1fbbbce4ce7049ce.zip
ssl: Add type specs for http_packet()
Change-Id: I07231ceab14d49c740967a0edfc9494328b96a62
-rw-r--r--lib/ssl/doc/src/ssl.xml40
-rw-r--r--lib/ssl/src/ssl.erl72
2 files changed, 110 insertions, 2 deletions
diff --git a/lib/ssl/doc/src/ssl.xml b/lib/ssl/doc/src/ssl.xml
index 69ab522da6..422bd6a19d 100644
--- a/lib/ssl/doc/src/ssl.xml
+++ b/lib/ssl/doc/src/ssl.xml
@@ -264,6 +264,46 @@
<name name="reason"/>
</datatype>
+ <datatype>
+ <name name="http_packet"/>
+ </datatype>
+
+ <datatype>
+ <name name="http_request"/>
+ </datatype>
+
+ <datatype>
+ <name name="http_response"/>
+ </datatype>
+
+ <datatype>
+ <name name="http_header"/>
+ </datatype>
+
+ <datatype>
+ <name name="http_error"/>
+ </datatype>
+
+ <datatype>
+ <name name="http_method"/>
+ </datatype>
+
+ <datatype>
+ <name name="http_uri"/>
+ </datatype>
+
+ <datatype>
+ <name name="http_version"/>
+ </datatype>
+
+ <datatype>
+ <name name="http_field"/>
+ </datatype>
+
+ <datatype>
+ <name name="http_string"/>
+ </datatype>
+
<datatype_title>TLS/DTLS OPTION DESCRIPTIONS - COMMON for SERVER and CLIENT</datatype_title>
<datatype>
diff --git a/lib/ssl/src/ssl.erl b/lib/ssl/src/ssl.erl
index f8aaf0b736..ef2cd4f557 100644
--- a/lib/ssl/src/ssl.erl
+++ b/lib/ssl/src/ssl.erl
@@ -244,6 +244,74 @@
bad_certificate_hash_value |
unknown_psk_identity |
no_application_protocol.
+-type http_packet() :: http_request() |
+ http_response() |
+ http_header() |
+ http_eoh |
+ http_error().
+-type http_request() :: {http_request, http_method(), http_uri(), http_version()}.
+-type http_response() :: {http_response, http_version(), integer(), http_string()}.
+-type http_header() :: {http_header, integer(), http_field(), Reserved :: term(),
+ Value :: http_string()}.
+-type http_error() :: {http_error, http_string()}.
+-type http_method() :: 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE'.
+-type http_uri() :: any().
+-type http_version() :: {Major :: integer(), Minor :: integer()}.
+-type http_field() :: 'Cache-Control' |
+ 'Connection' |
+ 'Date' |
+ 'Pragma' |
+ 'Transfer-Encoding' |
+ 'Upgrade' |
+ 'Via' |
+ 'Accept' |
+ 'Accept-Charset' |
+ 'Accept-Encoding' |
+ 'Accept-Language' |
+ 'Authorization' |
+ 'From' |
+ 'Host' |
+ 'If-Modified-Since' |
+ 'If-Match' |
+ 'If-None-Match' |
+ 'If-Range' |
+ 'If-Unmodified-Since' |
+ 'Max-Forwards' |
+ 'Proxy-Authorization' |
+ 'Range' |
+ 'Referer' |
+ 'User-Agent' |
+ 'Age' |
+ 'Location' |
+ 'Proxy-Authenticate' |
+ 'Public' |
+ 'Retry-After' |
+ 'Server' |
+ 'Vary' |
+ 'Warning' |
+ 'Www-Authenticate' |
+ 'Allow' |
+ 'Content-Base' |
+ 'Content-Encoding' |
+ 'Content-Language' |
+ 'Content-Length' |
+ 'Content-Location' |
+ 'Content-Md5' |
+ 'Content-Range' |
+ 'Content-Type' |
+ 'Etag' |
+ 'Expires' |
+ 'Last-Modified' |
+ 'Accept-Ranges' |
+ 'Set-Cookie' |
+ 'Set-Cookie2' |
+ 'X-Forwarded-For' |
+ 'Cookie' |
+ 'Keep-Alive' |
+ 'Proxy-Connection' |
+ http_string().
+-type http_string() :: string() | binary().
+
%% -------------------------------------------------------------------------------------------------------
-type common_option() :: {protocol, protocol()} |
{handshake, handshake_completion()} |
@@ -773,7 +841,7 @@ send(#sslsocket{pid = {ListenSocket, #config{transport_info = Info}}}, Data) ->
-spec recv(SslSocket, Length) -> {ok, Data} | {error, reason()} when
SslSocket :: sslsocket(),
Length :: integer(),
- Data :: binary() | list().
+ Data :: binary() | list() | http_packet().
recv(Socket, Length) ->
recv(Socket, Length, infinity).
@@ -781,7 +849,7 @@ recv(Socket, Length) ->
-spec recv(SslSocket, Length, Timeout) -> {ok, Data} | {error, reason()} when
SslSocket :: sslsocket(),
Length :: integer(),
- Data :: binary() | list(),
+ Data :: binary() | list() | http_packet(),
Timeout :: timeout().
recv(#sslsocket{pid = [Pid|_]}, Length, Timeout) when is_pid(Pid),