From 48f39402181d959cad88cb3f460210c007169f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 12 May 2021 11:13:47 +0200 Subject: Cowboy 2.9.0 --- .../1.8/manual/ranch.recv_proxy_header/index.html | 206 +++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 docs/en/ranch/1.8/manual/ranch.recv_proxy_header/index.html (limited to 'docs/en/ranch/1.8/manual/ranch.recv_proxy_header/index.html') diff --git a/docs/en/ranch/1.8/manual/ranch.recv_proxy_header/index.html b/docs/en/ranch/1.8/manual/ranch.recv_proxy_header/index.html new file mode 100644 index 00000000..91874776 --- /dev/null +++ b/docs/en/ranch/1.8/manual/ranch.recv_proxy_header/index.html @@ -0,0 +1,206 @@ + + + + + + + + + + Nine Nines: ranch:recv_proxy_header(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

ranch:recv_proxy_header(3)

+ +

Name

+

ranch:recv_proxy_header - Receive the PROXY protocol header

+

Description

+
+
recv_proxy_header(ranch:ref(), timeout())
+    -> {ok, ranch_proxy_header:proxy_info()}
+     | {error, Reason :: atom()}
+     | {error, protocol_error, HumanReadable :: atom()}
+
+

Receive the PROXY protocol header.

+

This function must be called before ranch:handshake/1,2 on newly accepted connections to read and parse the PROXY protocol header, if any.

+

Arguments

+
Ref
+

The listener name.

+
+
Timeout
+

Receive timeout in milliseconds.

+
+
+

Return value

+

An ok tuple is returned containing PROXY header information on success.

+

An error 2-tuple is returned when a socket error occurs.

+

An error 3-tuple is returned when a protocol error occurs and Ranch was not able to parse the PROXY header information. The third element contains a human-readable description of the error.

+

Changelog

+
  • 1.7: Function introduced. +
  • +
+

Examples

+
Receive the PROXY protocol header
+
+
start_link(Ref, _, Transport, Opts) ->
+    Pid = proc_lib:spawn_link(?MODULE, init,
+        [Ref, Transport, Opts]),
+    {ok, Pid}.
+
+init(Ref, Transport, Opts) ->
+    {ok, ProxyInfo} = ranch:recv_proxy_header(Ref, 1000),
+    {ok, Socket} = ranch:handshake(Ref),
+    loop(#state{ref=Ref, socket=Socket, transport=Transport,
+        proxy_info=ProxyInfo, opts=Opts}).
+
+

See also

+

ranch:start_listener(3), ranch:handshake(3), ranch:remove_connection(3), ranch(3)

+ + + + + + +
+ +
+ + +

+ Ranch + 1.8 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +

Like my work? Donate!

+

Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:

+
+ + + + + + + + + +

Recurring payment options are also available via GitHub Sponsors. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.

+ + + +
+
+
+
+ + + + + + + + + -- cgit v1.2.3