From 3d7d9e20fe46ed2839bc582d599abeac3ce19a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 17 Sep 2018 16:05:10 +0200 Subject: Gun 1.2.0 and Ranch 1.6.2 --- docs/en/gun/1.2/manual/gun.await/index.html | 224 +++++++++++++ docs/en/gun/1.2/manual/gun.await_body/index.html | 200 ++++++++++++ docs/en/gun/1.2/manual/gun.await_up/index.html | 192 +++++++++++ docs/en/gun/1.2/manual/gun.cancel/index.html | 178 ++++++++++ docs/en/gun/1.2/manual/gun.close/index.html | 170 ++++++++++ docs/en/gun/1.2/manual/gun.connect/index.html | 231 +++++++++++++ docs/en/gun/1.2/manual/gun.data/index.html | 189 +++++++++++ docs/en/gun/1.2/manual/gun.delete/index.html | 198 +++++++++++ docs/en/gun/1.2/manual/gun.flush/index.html | 183 +++++++++++ docs/en/gun/1.2/manual/gun.get/index.html | 201 ++++++++++++ docs/en/gun/1.2/manual/gun.head/index.html | 203 ++++++++++++ docs/en/gun/1.2/manual/gun.info/index.html | 174 ++++++++++ docs/en/gun/1.2/manual/gun.open/index.html | 194 +++++++++++ docs/en/gun/1.2/manual/gun.open_unix/index.html | 182 +++++++++++ docs/en/gun/1.2/manual/gun.options/index.html | 198 +++++++++++ docs/en/gun/1.2/manual/gun.patch/index.html | 221 +++++++++++++ docs/en/gun/1.2/manual/gun.post/index.html | 219 +++++++++++++ docs/en/gun/1.2/manual/gun.put/index.html | 219 +++++++++++++ docs/en/gun/1.2/manual/gun.request/index.html | 205 ++++++++++++ docs/en/gun/1.2/manual/gun.ws_send/index.html | 187 +++++++++++ docs/en/gun/1.2/manual/gun.ws_upgrade/index.html | 211 ++++++++++++ docs/en/gun/1.2/manual/gun/index.html | 397 +++++++++++++++++++++++ docs/en/gun/1.2/manual/gun_app/index.html | 163 ++++++++++ docs/en/gun/1.2/manual/gun_data/index.html | 187 +++++++++++ docs/en/gun/1.2/manual/gun_down/index.html | 193 +++++++++++ docs/en/gun/1.2/manual/gun_error/index.html | 186 +++++++++++ docs/en/gun/1.2/manual/gun_inform/index.html | 186 +++++++++++ docs/en/gun/1.2/manual/gun_push/index.html | 206 ++++++++++++ docs/en/gun/1.2/manual/gun_response/index.html | 189 +++++++++++ docs/en/gun/1.2/manual/gun_trailers/index.html | 181 +++++++++++ docs/en/gun/1.2/manual/gun_up/index.html | 177 ++++++++++ docs/en/gun/1.2/manual/gun_upgrade/index.html | 187 +++++++++++ docs/en/gun/1.2/manual/gun_ws/index.html | 183 +++++++++++ docs/en/gun/1.2/manual/index.html | 163 ++++++++++ 34 files changed, 6777 insertions(+) create mode 100644 docs/en/gun/1.2/manual/gun.await/index.html create mode 100644 docs/en/gun/1.2/manual/gun.await_body/index.html create mode 100644 docs/en/gun/1.2/manual/gun.await_up/index.html create mode 100644 docs/en/gun/1.2/manual/gun.cancel/index.html create mode 100644 docs/en/gun/1.2/manual/gun.close/index.html create mode 100644 docs/en/gun/1.2/manual/gun.connect/index.html create mode 100644 docs/en/gun/1.2/manual/gun.data/index.html create mode 100644 docs/en/gun/1.2/manual/gun.delete/index.html create mode 100644 docs/en/gun/1.2/manual/gun.flush/index.html create mode 100644 docs/en/gun/1.2/manual/gun.get/index.html create mode 100644 docs/en/gun/1.2/manual/gun.head/index.html create mode 100644 docs/en/gun/1.2/manual/gun.info/index.html create mode 100644 docs/en/gun/1.2/manual/gun.open/index.html create mode 100644 docs/en/gun/1.2/manual/gun.open_unix/index.html create mode 100644 docs/en/gun/1.2/manual/gun.options/index.html create mode 100644 docs/en/gun/1.2/manual/gun.patch/index.html create mode 100644 docs/en/gun/1.2/manual/gun.post/index.html create mode 100644 docs/en/gun/1.2/manual/gun.put/index.html create mode 100644 docs/en/gun/1.2/manual/gun.request/index.html create mode 100644 docs/en/gun/1.2/manual/gun.ws_send/index.html create mode 100644 docs/en/gun/1.2/manual/gun.ws_upgrade/index.html create mode 100644 docs/en/gun/1.2/manual/gun/index.html create mode 100644 docs/en/gun/1.2/manual/gun_app/index.html create mode 100644 docs/en/gun/1.2/manual/gun_data/index.html create mode 100644 docs/en/gun/1.2/manual/gun_down/index.html create mode 100644 docs/en/gun/1.2/manual/gun_error/index.html create mode 100644 docs/en/gun/1.2/manual/gun_inform/index.html create mode 100644 docs/en/gun/1.2/manual/gun_push/index.html create mode 100644 docs/en/gun/1.2/manual/gun_response/index.html create mode 100644 docs/en/gun/1.2/manual/gun_trailers/index.html create mode 100644 docs/en/gun/1.2/manual/gun_up/index.html create mode 100644 docs/en/gun/1.2/manual/gun_upgrade/index.html create mode 100644 docs/en/gun/1.2/manual/gun_ws/index.html create mode 100644 docs/en/gun/1.2/manual/index.html (limited to 'docs/en/gun/1.2/manual') diff --git a/docs/en/gun/1.2/manual/gun.await/index.html b/docs/en/gun/1.2/manual/gun.await/index.html new file mode 100644 index 00000000..fa887576 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.await/index.html @@ -0,0 +1,224 @@ + + + + + + + + + + Nine Nines: gun:await(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:await(3)

+ +

Name

+

gun:await - Wait for a response

+

Description

+
+
await(ConnPid, StreamRef)
+    -> await(ConnPid, StreamRef, 5000, MonitorRef)
+
+await(ConnPid, StreamRef, MonitorRef)
+    -> await(ConnPid, StreamRef, 5000, MonitorRef)
+
+await(ConnPid, StreamRef, Timeout)
+    -> await(ConnPid, StreamRef, Timeout, MonitorRef)
+
+await(ConnPid, StreamRef, Timeout, MonitorRef)
+    -> Result
+
+ConnPid    :: pid()
+StreamRef  :: reference()
+MonitorRef :: reference()
+Timeout    :: timeout()
+Result     :: tuple() - see below
+
+

Wait for a response.

+

This function waits for a message from the given stream and returns it as a tuple. An error will be returned should the process fail or a relevant message is not received within the specified duration.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
StreamRef
+

Identifier of the stream for the original request.

+
+
Timeout
+

How long to wait for a message, in milliseconds.

+
+
MonitorRef
+

Monitor for the Gun connection process.

+

A monitor is automatically created for the duration of this call when one is not provided.

+
+
+

Return value

+

A number of different tuples can be returned. They correspond to the message of the same name and they contain the same elements minus the pid and stream reference. Error tuples may also be returned when a timeout or an error occur.

+
+
Result :: {inform, Status, Headers}
+          {response, IsFin, Status, Headers}
+          {data, IsFin, Data}
+          {trailers, Trailers}
+          {push, NewStreamRef, Method, URI, Headers}
+          {error, Reason}
+
+Reason :: timeout | any()
+
+

Because the messages and returned tuples are equivalent, please refer to the manual pages for each message for further information:

+ +

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Wait for a response
+
+
StreamRef = gun:get(ConnPid, "/articles", [
+    {<<"accept">>, <<"text/html;q=1.0, application/xml;q=0.1">>}
+]).
+{response, nofin, 200, _Headers} = gun:await(ConnPid, StreamRef).
+{data, fin, <<"Hello world!">>} = gun:await(ConnPid, StreamRef).
+
+

See also

+

gun(3), gun:get(3), gun:head(3), gun:options(3), gun:patch(3), gun:post(3), gun:put(3), gun:delete(3), gun:request(3), gun:await_body(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.await_body/index.html b/docs/en/gun/1.2/manual/gun.await_body/index.html new file mode 100644 index 00000000..08af0b36 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.await_body/index.html @@ -0,0 +1,200 @@ + + + + + + + + + + Nine Nines: gun:await_body(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:await_body(3)

+ +

Name

+

gun:await_body - Wait for the complete response body

+

Description

+
+
await_body(ConnPid, StreamRef)
+    -> await_body(ConnPid, StreamRef, 5000, MonitorRef)
+
+await_body(ConnPid, StreamRef, MonitorRef)
+    -> await_body(ConnPid, StreamRef, 5000, MonitorRef)
+
+await_body(ConnPid, StreamRef, Timeout)
+    -> await_body(ConnPid, StreamRef, Timeout, MonitorRef)
+
+await_body(ConnPid, StreamRef, Timeout, MonitorRef)
+    -> {ok, Body} | {ok, Body, Trailers} | {error, Reason}
+
+ConnPid    :: pid()
+StreamRef  :: reference()
+MonitorRef :: reference()
+Timeout    :: timeout()
+Body       :: binary()
+Trailers   :: [{binary(), binary()}]
+Reason     :: timeout | any()
+
+

Wait for the complete response body.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
StreamRef
+

Identifier of the stream for the original request.

+
+
Timeout
+

How long to wait for each message, in milliseconds.

+
+
MonitorRef
+

Monitor for the Gun connection process.

+

A monitor is automatically created for the duration of this call when one is not provided.

+
+
+

Return value

+

The body is returned, possibly with trailers if the request contained a te: trailers header. Error tuples may also be returned when a timeout or an error occur.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Wait for the complete response body
+
+
StreamRef = gun:get(ConnPid, "/articles", [
+    {<<"accept">>, <<"text/html;q=1.0, application/xml;q=0.1">>}
+]).
+{response, nofin, 200, _Headers} = gun:await(ConnPid, StreamRef).
+{ok, _Body} = gun:await_body(ConnPid, StreamRef).
+
+

See also

+

gun(3), gun:get(3), gun:head(3), gun:options(3), gun:patch(3), gun:post(3), gun:put(3), gun:delete(3), gun:request(3), gun:await(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.await_up/index.html b/docs/en/gun/1.2/manual/gun.await_up/index.html new file mode 100644 index 00000000..f19345ac --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.await_up/index.html @@ -0,0 +1,192 @@ + + + + + + + + + + Nine Nines: gun:await_up(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:await_up(3)

+ +

Name

+

gun:await_up - Wait for the connection to be up

+

Description

+
+
await_up(ConnPid)
+    -> await_up(ConnPid, 5000, MonitorRef)
+
+await_up(ConnPid, MonitorRef)
+    -> await_up(ConnPid, 5000, MonitorRef)
+
+await_up(ConnPid, Timeout)
+    -> await_up(ConnPid, Timeout, MonitorRef)
+
+await_up(ConnPid, Timeout, MonitorRef)
+    -> {ok, Protocol} | {error, Reason}
+
+ConnPid    :: pid()
+MonitorRef :: reference()
+Timeout    :: timeout()
+Protocol   :: http | http2
+Reason     :: timeout | any()
+
+

Wait for the connection to be up.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
Timeout
+

How long to wait for, in milliseconds.

+
+
MonitorRef
+

Monitor for the Gun connection process.

+

A monitor is automatically created for the duration of this call when one is not provided.

+
+
+

Return value

+

The protocol selected for this connection. It can be used to determine the capabilities of the server. Error tuples may also be returned when a timeout or an error occur.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Wait for the connection to be up
+
+
{ok, ConnPid} = gun:open("example.org", 443).
+{ok, _} = gun:await_up(ConnPid).
+
+

See also

+

gun(3), gun:open(3), gun:open_unix(3), gun_up(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.cancel/index.html b/docs/en/gun/1.2/manual/gun.cancel/index.html new file mode 100644 index 00000000..4ed0dd11 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.cancel/index.html @@ -0,0 +1,178 @@ + + + + + + + + + + Nine Nines: gun:cancel(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:cancel(3)

+ +

Name

+

gun:cancel - Cancel the given stream

+

Description

+
+
cancel(ConnPid, StreamRef) -> ok
+
+ConnPid   :: pid()
+StreamRef :: reference()
+
+

Cancel the given stream.

+

The behavior of this function depends on the protocol selected.

+

HTTP/1.1 does not support this feature. Gun will simply silence the stream and stop relaying messages. Gun may also decide to close the connection if the response body is too large, to avoid wasting time and bandwidth.

+

HTTP/2 allows cancelling streams at any time.

+

This function is asynchronous. Messages related to this stream may still be sent after the function returns.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
StreamRef
+

Identifier of the stream for the original request.

+
+
+

Return value

+

The atom ok is returned.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Cancel a stream
+
+
gun:cancel(ConnPid, StreamRef).
+
+

See also

+

gun(3), gun:get(3), gun:head(3), gun:options(3), gun:patch(3), gun:post(3), gun:put(3), gun:delete(3), gun:request(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.close/index.html b/docs/en/gun/1.2/manual/gun.close/index.html new file mode 100644 index 00000000..ed7bb667 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.close/index.html @@ -0,0 +1,170 @@ + + + + + + + + + + Nine Nines: gun:close(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:close(3)

+ +

Name

+

gun:close - Brutally close the connection

+

Description

+
+
close(ConnPid) -> ok
+
+ConnPid :: pid()
+
+

Brutally close the connection.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
+

Return value

+

The atom ok is returned.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Close the connection
+
+
ok = gun:close(ConnPid).
+
+

See also

+

gun(3), gun:open(3), gun:open_unix(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.connect/index.html b/docs/en/gun/1.2/manual/gun.connect/index.html new file mode 100644 index 00000000..b8fba81f --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.connect/index.html @@ -0,0 +1,231 @@ + + + + + + + + + + Nine Nines: gun:connect(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:connect(3)

+ +

Name

+

gun:connect - Establish a tunnel to the origin server

+

Description

+
+
connect(ConnPid, Destination)
+    -> connect(ConnPid, Destination, [], #{}).
+
+connect(ConnPid, Destination, Headers)
+    -> connect(ConnPid, Destination, Headers, #{}).
+
+connect(ConnPid, Destination, Headers, ReqOpts)
+    -> StreamRef
+
+ConnPid     :: pid()
+Destination :: gun:connect_destination()
+Headers     :: [{binary(), iodata()}]
+ReqOpts     :: gun:req_opts()
+StreamRef   :: reference()
+
+

Establish a tunnel to the origin server.

+

This feature is currently only available for HTTP/1.1 connections. Upon successful completion of the CONNECT request a tunnel is established and subsequent requests will go through the tunnel.

+

Gun will not automatically re-issue the CONNECT request upon reconnection to the proxy server. The gun_up message can be used to know when the tunnel needs to be established again.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
Destination
+

Destination of the CONNECT request.

+
+
Headers
+

Additional request headers.

+
+
ReqOpts
+

Request options.

+
+
+

Return value

+

A reference that identifies the newly created stream is returned. It is this reference that must be passed in subsequent calls and will be received in messages related to this new stream.

+

Changelog

+
  • 1.2: Function introduced. +
  • +
+

Examples

+
Establish a tunnel
+
+
{ok, ConnPid} = gun:open("proxy.example.org", 1080),
+{ok, http} = gun:await_up(ConnPid),
+StreamRef = gun:connect(ConnPid, #{
+    host => "origin-server.example.org",
+    port => 80
+}),
+{response, fin, 200, _} = gun:await(ConnPid, StreamRef),
+%% Subsequent requests will be sent to origin-server.example.org.
+
+
Establish a tunnel for a secure HTTP/2 connection
+
+
{ok, ConnPid} = gun:open("proxy.example.org", 1080),
+{ok, http} = gun:await_up(ConnPid),
+StreamRef = gun:connect(ConnPid, #{
+    host => "origin-server.example.org",
+    port => 80,
+    protocol => http2,
+    transport => tls
+}),
+{response, fin, 200, _} = gun:await(ConnPid, StreamRef),
+%% Subsequent requests will be sent to origin-server.example.org.
+
+
Establish a tunnel using proxy authorization
+
+
{ok, ConnPid} = gun:open("proxy.example.org", 1080),
+{ok, http} = gun:await_up(ConnPid),
+StreamRef = gun:connect(ConnPid, #{
+    host => "origin-server.example.org",
+    port => 80,
+    username => "essen",
+    password => "myrealpasswordis"
+}),
+{response, fin, 200, _} = gun:await(ConnPid, StreamRef),
+%% Subsequent requests will be sent to origin-server.example.org.
+
+

See also

+

gun(3), gun:await_up(3), gun_up(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.data/index.html b/docs/en/gun/1.2/manual/gun.data/index.html new file mode 100644 index 00000000..1aead1f3 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.data/index.html @@ -0,0 +1,189 @@ + + + + + + + + + + Nine Nines: gun:data(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:data(3)

+ +

Name

+

gun:data - Stream the body of a request

+

Description

+
+
data(ConnPid, StreamRef, IsFin, Data) -> ok
+
+ConnPid   :: pid()
+StreamRef :: reference()
+IsFin     :: fin | nofin
+Data      :: iodata()
+
+

Stream the body of a request.

+

This function can only be used if the original request had headers indicating that a body would be streamed.

+

All calls to this function must use the nofin flag except for the last which must use fin to indicate the end of the request body.

+

Empty data is allowed regardless of the value of IsFin. Gun may or may not send empty data chunks, however.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
StreamRef
+

Identifier of the stream for the original request.

+
+
IsFin
+

Whether this message terminates the request.

+
+
Data
+

All or part of the response body.

+
+
+

Return value

+

The atom ok is returned.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Stream the body of a request
+
+
StreamRef = gun:put(ConnPid, "/lang/fr_FR/hello", [
+    {<<"content-type">>, <<"text/plain">>}
+]).
+gun:data(ConnPid, StreamRef, nofin, <<"Bonjour !\n">>).
+gun:data(ConnPid, StreamRef, fin, <<"Bonsoir !\n">>).
+
+

See also

+

gun(3), gun:patch(3), gun:post(3), gun:put(3), gun:request(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.delete/index.html b/docs/en/gun/1.2/manual/gun.delete/index.html new file mode 100644 index 00000000..c6034ac6 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.delete/index.html @@ -0,0 +1,198 @@ + + + + + + + + + + Nine Nines: gun:delete(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:delete(3)

+ +

Name

+

gun:delete - Delete a resource

+

Description

+
+
delete(ConnPid, Path)
+    -> delete(ConnPid, Path, [], #{}).
+
+delete(ConnPid, Path, Headers)
+    -> delete(ConnPid, Path, Headers, #{})
+
+delete(ConnPid, Path, Headers, ReqOpts)
+    -> StreamRef
+
+ConnPid   :: pid()
+Path      :: iodata()
+Headers   :: [{binary(), iodata()}]
+ReqOpts   :: gun:req_opts()
+StreamRef :: reference()
+
+

Delete a resource.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
Path
+

Path to the resource.

+
+
Headers
+

Additional request headers.

+
+
ReqOpts
+

Request options.

+
+
+

Return value

+

A reference that identifies the newly created stream is returned. It is this reference that must be passed in subsequent calls and will be received in messages related to this new stream.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Delete a resource
+
+
StreamRef = gun:delete(ConnPid, "/drafts/123").
+
+
Delete a resource with request options
+
+
StreamRef = gun:delete(ConnPid, "/drafts/123", [],
+    #{reply_to => ReplyToPid}).
+
+

See also

+

gun(3), gun:put(3), gun:await(3), gun:await_body(3), gun_push(3), gun_inform(3), gun_response(3), gun_data(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.flush/index.html b/docs/en/gun/1.2/manual/gun.flush/index.html new file mode 100644 index 00000000..c9f0c895 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.flush/index.html @@ -0,0 +1,183 @@ + + + + + + + + + + Nine Nines: gun:flush(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:flush(3)

+ +

Name

+

gun:flush - Flush all messages related to a connection or a stream

+

Description

+
+
flush(ConnPid) -> ok
+flush(StreamRef) -> ok
+
+ConnPid    :: pid()
+StreamRef  :: reference()
+
+

Flush all messages related to a connection or a stream.

+

Arguments

+

Either of these arguments may be provided:

+
ConnPid
+

The pid of the Gun connection process.

+
+
StreamRef
+

Identifier of the stream for the original request.

+
+
+

Return value

+

The atom ok is returned.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Flush all messages from a connection
+
+
gun:flush(ConnPid).
+
+
Flush messages from a single stream
+
+
gun:flush(StreamRef).
+
+

See also

+

gun(3), gun:await(3), gun:await_body(3), gun:await_up(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.get/index.html b/docs/en/gun/1.2/manual/gun.get/index.html new file mode 100644 index 00000000..b438ec66 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.get/index.html @@ -0,0 +1,201 @@ + + + + + + + + + + Nine Nines: gun:get(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:get(3)

+ +

Name

+

gun:get - Get a resource representation

+

Description

+
+
get(ConnPid, Path)
+    -> get(ConnPid, Path, [], #{}).
+
+get(ConnPid, Path, Headers)
+    -> get(ConnPid, Path, Headers, #{})
+
+get(ConnPid, Path, Headers, ReqOpts)
+    -> StreamRef
+
+ConnPid   :: pid()
+Path      :: iodata()
+Headers   :: [{binary(), iodata()}]
+ReqOpts   :: gun:req_opts()
+StreamRef :: reference()
+
+

Get a resource representation.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
Path
+

Path to the resource.

+
+
Headers
+

Additional request headers.

+
+
ReqOpts
+

Request options.

+
+
+

Return value

+

A reference that identifies the newly created stream is returned. It is this reference that must be passed in subsequent calls and will be received in messages related to this new stream.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Get a resource representation
+
+
StreamRef = gun:get(ConnPid, "/articles", [
+    {<<"accept">>, <<"text/html;q=1.0, application/xml;q=0.1">>}
+]).
+
+
Get a resource representation with request options
+
+
StreamRef = gun:get(ConnPid, "/articles", [], #{
+    reply_to => ReplyToPid
+}).
+
+

See also

+

gun(3), gun:head(3), gun:await(3), gun:await_body(3), gun_push(3), gun_inform(3), gun_response(3), gun_data(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.head/index.html b/docs/en/gun/1.2/manual/gun.head/index.html new file mode 100644 index 00000000..08ae2464 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.head/index.html @@ -0,0 +1,203 @@ + + + + + + + + + + Nine Nines: gun:head(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:head(3)

+ +

Name

+

gun:head - Get headers of a resource representation

+

Description

+
+
head(ConnPid, Path)
+    -> head(ConnPid, Path, [], #{}).
+
+head(ConnPid, Path, Headers)
+    -> head(ConnPid, Path, Headers, #{})
+
+head(ConnPid, Path, Headers, ReqOpts)
+    -> StreamRef
+
+ConnPid   :: pid()
+Path      :: iodata()
+Headers   :: [{binary(), iodata()}]
+ReqOpts   :: gun:req_opts()
+StreamRef :: reference()
+
+

Get headers of a resource representation.

+

This function performs the same operation as gun:get(3), except the server will not send the resource representation, only the response's status code and headers.

+

While servers are supposed to send the same headers as for a GET request, they sometimes will not. For example the content-length header may be dropped from the response.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
Path
+

Path to the resource.

+
+
Headers
+

Additional request headers.

+
+
ReqOpts
+

Request options.

+
+
+

Return value

+

A reference that identifies the newly created stream is returned. It is this reference that must be passed in subsequent calls and will be received in messages related to this new stream.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Get headers of a resource representation
+
+
StreamRef = gun:head(ConnPid, "/articles", [
+    {<<"accept">>, <<"text/html;q=1.0, application/xml;q=0.1">>}
+]).
+
+
Get headers of a resource representation with request options
+
+
StreamRef = gun:head(ConnPid, "/articles", [], #{
+    reply_to => ReplyToPid
+}).
+
+

See also

+

gun(3), gun:head(3), gun:await(3), gun_push(3), gun_inform(3), gun_response(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.info/index.html b/docs/en/gun/1.2/manual/gun.info/index.html new file mode 100644 index 00000000..4518add7 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.info/index.html @@ -0,0 +1,174 @@ + + + + + + + + + + Nine Nines: gun:info(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:info(3)

+ +

Name

+

gun:info - Obtain information about the connection

+

Description

+
+
info(ConnPid) -> Info
+
+ConnPid :: pid()
+Info :: #{
+    sock_ip   => inet:ip_address(),
+    sock_port => inet:port_number()
+}
+
+

Obtain information about the connection.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
+

Return value

+

A map is returned containing various informations about the connection.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Obtain information about the connection
+
+
Info = gun:info(ConnPid).
+
+

See also

+

gun(3), gun:open(3), gun:open_unix(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.open/index.html b/docs/en/gun/1.2/manual/gun.open/index.html new file mode 100644 index 00000000..f8bf4d98 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.open/index.html @@ -0,0 +1,194 @@ + + + + + + + + + + Nine Nines: gun:open(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:open(3)

+ +

Name

+

gun:open - Open a connection to the given host and port

+

Description

+
+
open(Host, Port)       -> open(Host, Port, #{})
+open(Host, Port, Opts) -> {ok, pid()} | {error, any()}
+
+Host :: inet:hostname() | inet:ip_address()
+Port :: inet:port_number()
+Opts :: gun:opts()
+
+

Open a connection to the given host and port.

+

Arguments

+
Host
+

Host or IP address to connect to.

+
+
Port
+

Port to connect to.

+
+
Opts
+

Options for this connection.

+
+
+

Return value

+

The pid of the newly created Gun process is returned. Note that this does not indicate that the connection has been successfully opened; the gun_up(3) message will be sent for that.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Connect to a server
+
+
{ok, ConnPid} = gun:open("example.org", 443).
+
+
Connect to a server with custom options
+
+
{ok, ConnPid} = gun:open("example.org", 443,
+    #{protocols => [http2]}).
+
+
Connect to a server using its IP address
+
+
{ok, ConnPid} = gun:open({127,0,0,1}, 443).
+
+

See also

+

gun(3), gun:open_unix(3), gun:await_up(3), gun_up(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.open_unix/index.html b/docs/en/gun/1.2/manual/gun.open_unix/index.html new file mode 100644 index 00000000..d126d75c --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.open_unix/index.html @@ -0,0 +1,182 @@ + + + + + + + + + + Nine Nines: gun:open_unix(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:open_unix(3)

+ +

Name

+

gun:open_unix - Open a connection to the given Unix domain socket

+

Description

+
+
open_unix(SocketPath, Opts) -> {ok, pid()} | {error, any()}
+
+SocketPath :: string()
+Opts       :: gun:opts()
+
+

Open a connection to the given Unix domain socket.

+

Arguments

+
SocketPath
+

Path to the Unix domain socket to connect to.

+
+
Opts
+

Options for this connection.

+
+
+

Return value

+

The pid of the newly created Gun process is returned. Note that this does not indicate that the connection has been successfully opened; the gun_up(3) message will be sent for that.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Connect to a server via a Unix domain socket
+
+
{ok, ConnPid} = gun:open_unix("/var/run/dbus/system_bus_socket", #{}).
+
+
Connect to a server via a Unix domain socket with custom options
+
+
{ok, ConnPid} = gun:open_unix("/var/run/dbus/system_bus_socket",
+    #{protocols => [http2]}).
+
+

See also

+

gun(3), gun:open(3), gun:await_up(3), gun_up(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.options/index.html b/docs/en/gun/1.2/manual/gun.options/index.html new file mode 100644 index 00000000..e883e2ab --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.options/index.html @@ -0,0 +1,198 @@ + + + + + + + + + + Nine Nines: gun:options(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:options(3)

+ +

Name

+

gun:options - Query the capabilities of the server or a resource

+

Description

+
+
options(ConnPid, Path)
+    -> options(ConnPid, Path, [], #{}).
+
+options(ConnPid, Path, Headers)
+    -> options(ConnPid, Path, Headers, #{})
+
+options(ConnPid, Path, Headers, ReqOpts)
+    -> StreamRef
+
+ConnPid   :: pid()
+Path      :: iodata()
+Headers   :: [{binary(), iodata()}]
+ReqOpts   :: gun:req_opts()
+StreamRef :: reference()
+
+

Query the capabilities of the server or a resource.

+

The special path "*" can be used to obtain information about the server as a whole. Any other path will return information about that resource specifically.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
Path
+

Path to the resource.

+
+
Headers
+

Additional request headers.

+
+
ReqOpts
+

Request options.

+
+
+

Return value

+

A reference that identifies the newly created stream is returned. It is this reference that must be passed in subsequent calls and will be received in messages related to this new stream.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Query the capabilities of the server
+
+
StreamRef = gun:options(ConnPid, "*").
+
+
Query the capabilities of a resource
+
+
StreamRef = gun:options(ConnPid, "/articles").
+
+

See also

+

gun(3), gun:await(3), gun:await_body(3), gun_inform(3), gun_response(3), gun_data(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.patch/index.html b/docs/en/gun/1.2/manual/gun.patch/index.html new file mode 100644 index 00000000..a7a70c67 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.patch/index.html @@ -0,0 +1,221 @@ + + + + + + + + + + Nine Nines: gun:patch(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:patch(3)

+ +

Name

+

gun:patch - Apply a set of changes to a resource

+

Description

+
+
patch(ConnPid, Path, Headers)
+    -> StreamRef
+
+patch(ConnPid, Path, Headers, Body)
+    -> patch(ConnPid, Path, Headers, Body, #{})
+
+patch(ConnPid, Path, Headers, Body, ReqOpts)
+    -> StreamRef
+
+ConnPid   :: pid()
+Path      :: iodata()
+Headers   :: [{binary(), iodata()}]
+Body      :: iodata()
+ReqOpts   :: gun:req_opts()
+StreamRef :: reference()
+
+

Apply a set of changes to a resource.

+

The behavior of this function varies depending on whether a body is provided.

+

The function patch/3 expects either a content-length or content-type header to indicate that a body will be sent afterwards. The body can then be sent using gun:data(3).

+

The function patch/4,5 sends the entire request, including the request body, immediately. It is therefore not possible to use gun:data(3) after that. You should provide a content-type header. Gun will set the content-length header automatically.

+

The body sent in this request should be a patch document with instructions on how to update the resource.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
Path
+

Path to the resource.

+
+
Headers
+

Additional request headers.

+
+
Body
+

Request body.

+
+
ReqOpts
+

Request options.

+
+
+

Return value

+

A reference that identifies the newly created stream is returned. It is this reference that must be passed in subsequent calls and will be received in messages related to this new stream.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Patch a resource
+
+
StreamRef = gun:patch(ConnPid, "/users/1",
+    [{<<"content-type">>, <<"application/json-patch+json">>}],
+    <<"[{\"op\":\"add\",\"path\":\"/baz\",\"value\":\"qux\"}]">>).
+
+
Patch a resource in multiple calls
+
+
StreamRef = gun:patch(ConnPid, "/users/1", [
+    {<<"content-type">>, <<"application/json-patch+json">>}
+]).
+gun:data(ConnPid, StreamRef, fin,
+    <<"[{\"op\":\"add\",\"path\":\"/baz\",\"value\":\"qux\"}]">>).
+
+
Patch a resource with request options
+
+
StreamRef = gun:patch(ConnPid, "/users/1",
+    [{<<"content-type">>, <<"application/json-patch+json">>}],
+    <<"[{\"op\":\"add\",\"path\":\"/baz\",\"value\":\"qux\"}]">>,
+    #{reply_to => ReplyToPid}).
+
+

See also

+

gun(3), gun:post(3), gun:put(3), gun:await(3), gun:await_body(3), gun_push(3), gun_inform(3), gun_response(3), gun_data(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.post/index.html b/docs/en/gun/1.2/manual/gun.post/index.html new file mode 100644 index 00000000..080bee32 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.post/index.html @@ -0,0 +1,219 @@ + + + + + + + + + + Nine Nines: gun:post(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:post(3)

+ +

Name

+

gun:post - Process the enclosed representation according to a resource's own semantics

+

Description

+
+
post(ConnPid, Path, Headers)
+    -> StreamRef
+
+post(ConnPid, Path, Headers, Body)
+    -> post(ConnPid, Path, Headers, Body, #{})
+
+post(ConnPid, Path, Headers, Body, ReqOpts)
+    -> StreamRef
+
+ConnPid   :: pid()
+Path      :: iodata()
+Headers   :: [{binary(), iodata()}]
+Body      :: iodata()
+ReqOpts   :: gun:req_opts()
+StreamRef :: reference()
+
+

Process the enclosed representation according to a resource's own semantics.

+

The behavior of this function varies depending on whether a body is provided.

+

The function post/3 expects either a content-length or content-type header to indicate that a body will be sent afterwards. The body can then be sent using gun:data(3).

+

The function post/4,5 sends the entire request, including the request body, immediately. It is therefore not possible to use gun:data(3) after that. You should provide a content-type header. Gun will set the content-length header automatically.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
Path
+

Path to the resource.

+
+
Headers
+

Additional request headers.

+
+
Body
+

Request body.

+
+
ReqOpts
+

Request options.

+
+
+

Return value

+

A reference that identifies the newly created stream is returned. It is this reference that must be passed in subsequent calls and will be received in messages related to this new stream.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Post to a resource
+
+
StreamRef = gun:post(ConnPid, "/search",
+    [{<<"content-type">>, <<"application/x-www-form-urlencoded">>}],
+    <<"q=nine%20nines">>).
+
+
Post to a resource in multiple calls
+
+
StreamRef = gun:post(ConnPid, "/search", [
+    {<<"content-type">>, <<"application/x-www-form-urlencoded">>}
+]).
+gun:data(ConnPid, StreamRef, fin, <<"q=nine%20nines">>).
+
+
Post to a resource with request options
+
+
StreamRef = gun:post(ConnPid, "/search",
+    [{<<"content-type">>, <<"application/x-www-form-urlencoded">>}],
+    <<"q=nine%20nines">>,
+    #{reply_to => ReplyToPid}).
+
+

See also

+

gun(3), gun:patch(3), gun:put(3), gun:await(3), gun:await_body(3), gun_push(3), gun_inform(3), gun_response(3), gun_data(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.put/index.html b/docs/en/gun/1.2/manual/gun.put/index.html new file mode 100644 index 00000000..bbdd0c75 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.put/index.html @@ -0,0 +1,219 @@ + + + + + + + + + + Nine Nines: gun:put(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:put(3)

+ +

Name

+

gun:put - Create or replace a resource

+

Description

+
+
put(ConnPid, Path, Headers)
+    -> StreamRef
+
+put(ConnPid, Path, Headers, Body)
+    -> put(ConnPid, Path, Headers, Body, #{})
+
+put(ConnPid, Path, Headers, Body, ReqOpts)
+    -> StreamRef
+
+ConnPid   :: pid()
+Path      :: iodata()
+Headers   :: [{binary(), iodata()}]
+Body      :: iodata()
+ReqOpts   :: gun:req_opts()
+StreamRef :: reference()
+
+

Create or replace a resource.

+

The behavior of this function varies depending on whether a body is provided.

+

The function put/3 expects either a content-length or content-type header to indicate that a body will be sent afterwards. The body can then be sent using gun:data(3).

+

The function put/4,5 sends the entire request, including the request body, immediately. It is therefore not possible to use gun:data(3) after that. You should provide a content-type header. Gun will set the content-length header automatically.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
Path
+

Path to the resource.

+
+
Headers
+

Additional request headers.

+
+
Body
+

Request body.

+
+
ReqOpts
+

Request options.

+
+
+

Return value

+

A reference that identifies the newly created stream is returned. It is this reference that must be passed in subsequent calls and will be received in messages related to this new stream.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Put a resource
+
+
StreamRef = gun:put(ConnPid, "/lang/fr_FR/hello",
+    [{<<"content-type">>, <<"text/plain">>}],
+    <<"Bonjour !">>).
+
+
Put a resource in multiple calls
+
+
StreamRef = gun:put(ConnPid, "/lang/fr_FR/hello", [
+    {<<"content-type">>, <<"text/plain">>}
+]).
+gun:data(ConnPid, StreamRef, fin, <<"Bonjour !">>).
+
+
Put a resource with request options
+
+
StreamRef = gun:put(ConnPid, "/lang/fr_FR/hello",
+    [{<<"content-type">>, <<"text/plain">>}],
+    <<"Bonjour !">>,
+    #{reply_to => ReplyToPid}).
+
+

See also

+

gun(3), gun:patch(3), gun:post(3), gun:await(3), gun:await_body(3), gun_push(3), gun_inform(3), gun_response(3), gun_data(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.request/index.html b/docs/en/gun/1.2/manual/gun.request/index.html new file mode 100644 index 00000000..185043ee --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.request/index.html @@ -0,0 +1,205 @@ + + + + + + + + + + Nine Nines: gun:request(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:request(3)

+ +

Name

+

gun:request - Perform the given request

+

Description

+
+
request(ConnPid, Method, Path, Headers)
+    -> StreamRef
+
+request(ConnPid, Method, Path, Headers, Body)
+    -> request(ConnPid, Method, Path, Headers, Body, #{})
+
+request(ConnPid, Method, Path, Headers, Body, ReqOpts)
+    -> StreamRef
+
+ConnPid   :: pid()
+Method    :: binary()
+Path      :: iodata()
+Headers   :: [{binary(), iodata()}]
+Body      :: iodata()
+ReqOpts   :: gun:req_opts()
+StreamRef :: reference()
+
+

Perform the given request.

+

This is a general purpose function that should only be used when other method-specific functions do not apply.

+

The behavior of this function varies depending on whether a body is provided.

+

The function request/4 expects either a content-length or content-type header to indicate that a body will be sent afterwards. Gun will assume the request has no body otherwise. The body can then be sent using gun:data(3).

+

The function request/5,6 sends the entire request, including the request body, immediately. It is therefore not possible to use gun:data(3) after that. You should provide a content-type header. Gun will set the content-length header automatically.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
Method
+

Method to be used for the request.

+
+
Path
+

Path to the resource.

+
+
Headers
+

Additional request headers.

+
+
Body
+

Request body.

+
+
ReqOpts
+

Request options.

+
+
+

Return value

+

A reference that identifies the newly created stream is returned. It is this reference that must be passed in subsequent calls and will be received in messages related to this new stream.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Perform a request
+
+
StreamRef = gun:request(ConnPid, <<"PUT">>,
+    "/lang/fr_FR/hello",
+    [{<<"content-type">>, <<"text/plain">>}],
+    <<"Bonjour !">>).
+
+

See also

+

gun(3), gun:await(3), gun:await_body(3), gun_push(3), gun_inform(3), gun_response(3), gun_data(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.ws_send/index.html b/docs/en/gun/1.2/manual/gun.ws_send/index.html new file mode 100644 index 00000000..6d31659b --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.ws_send/index.html @@ -0,0 +1,187 @@ + + + + + + + + + + Nine Nines: gun:ws_send(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:ws_send(3)

+ +

Name

+

gun:ws_send - Send Websocket frames

+

Description

+
+
ws_send(ConnPid, Frames) -> ok
+
+ConnPid :: pid()
+Frames  :: Frame | [Frame]
+Frame   :: close | ping | pong
+         | {text | binary | close | ping | pong, iodata()}
+         | {close, non_neg_integer(), iodata()}
+
+

Send Websocket frames.

+

The connection must first be upgraded to Websocket using the function gun:ws_upgrade(3).

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
Frames
+

A Websocket frame.

+
+
+ +

Return value

+

The atom ok is returned.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Send a single frame
+
+
gun:ws_send(ConnPid, {text, <<"Hello world!">>}).
+
+ + + + + + + + +

See also

+

gun(3), gun:ws_upgrade(3), gun_upgrade(3), gun_ws(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun.ws_upgrade/index.html b/docs/en/gun/1.2/manual/gun.ws_upgrade/index.html new file mode 100644 index 00000000..f2a5589c --- /dev/null +++ b/docs/en/gun/1.2/manual/gun.ws_upgrade/index.html @@ -0,0 +1,211 @@ + + + + + + + + + + Nine Nines: gun:ws_upgrade(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun:ws_upgrade(3)

+ +

Name

+

gun:ws_upgrade - Upgrade to Websocket

+

Description

+
+
ws_upgrade(ConnPid, Path)
+    -> ws_upgrade(ConnPid, Path, [])
+
+ws_upgrade(ConnPid, Path, Headers)
+    -> StreamRef
+
+ws_upgrade(ConnPid, Path, Headers, WsOpts)
+    -> StreamRef
+
+ConnPid   :: pid()
+Path      :: iodata()
+Headers   :: [{binary(), iodata()}]
+WsOpts    :: gun:ws_opts
+StreamRef :: reference()
+
+

Upgrade to Websocket.

+

The behavior of this function depends on the protocol selected.

+

HTTP/1.1 cannot handle Websocket and HTTP requests concurrently. The upgrade, if successful, will result in the complete takeover of the connection. Any subsequent HTTP requests will be rejected.

+

Gun does not currently support Websocket over HTTP/2.

+

By default Gun will take the Websocket options from the connection's ws_opts.

+

Arguments

+
ConnPid
+

The pid of the Gun connection process.

+
+
Path
+

Path to the resource.

+
+
Headers
+

Additional request headers.

+
+
WsOpts
+

Configuration for the Websocket protocol.

+
+
+

Return value

+

A reference that identifies the newly created stream is returned. It is this reference that must be passed in subsequent calls and will be received in messages related to this new stream.

+

Changelog

+
  • 1.0: Function introduced. +
  • +
+

Examples

+
Upgrade to Websocket
+
+
StreamRef = gun:ws_upgrade(ConnPid, "/ws", [
+    {<<"sec-websocket-protocol">>, <<"chat">>}
+]).
+receive
+    {gun_upgrade, ConnPid, StreamRef, [<<"websocket">>], _} ->
+        ok
+after 5000 ->
+    error(timeout)
+end.
+
+
Upgrade to Websocket with different options
+
+
StreamRef = gun:ws_upgrade(ConnPid, "/ws", [], #{
+    compress => false
+}).
+
+

See also

+

gun(3), gun:ws_send(3), gun_upgrade(3), gun_ws(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun/index.html b/docs/en/gun/1.2/manual/gun/index.html new file mode 100644 index 00000000..ea394fc1 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun/index.html @@ -0,0 +1,397 @@ + + + + + + + + + + Nine Nines: gun(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun(3)

+ +

Name

+

gun - Asynchronous HTTP client

+

Description

+

The gun module provides an asynchronous interface for connecting and communicating with Web servers over HTTP, HTTP/2 or Websocket.

+

Exports

+

Connection:

+ + + +

Requests:

+ +

Proxies:

+ +

Messages:

+ +

Streams:

+ +

Websocket:

+ +

Messages

+

Gun will inform the calling process of events asynchronously by sending any of the following messages:

+

Connection:

+ +

Responses:

+ +

Websocket:

+ +

The response messages will be sent to the process that opened the connection by default. The reply_to request option can be used to redirect request-specific messages to a different process.

+

Types

+

connect_destination()

+
+
connect_destination() :: #{
+    host      := inet:hostname() | inet:ip_address(),
+    port      := inet:port_number(),
+
+    username  => iodata(),
+    password  => iodata(),
+    protocol  => http | http2,
+    transport => tcp | tls,
+
+    tls_opts              => [ssl:connect_option()],
+    tls_handshake_timeout => timeout()
+}
+
+

Destination of a CONNECT request.

+

The default value, if any, is given next to the option name:

+
host, port
+

Destination hostname and port number. Mandatory.

+

Upon successful completion of the CONNECT request, Gun will begin using these as the host and port of the origin server for subsequent requests.

+
+
username, password
+

Proxy authorization credentials. They are only sent when both options are provided.

+
+
protocol (http)
+

Protocol that will be used for tunneled requests.

+
+
transport (tcp)
+

Transport that will be used for tunneled requests. Note that due to Erlang/OTP limitations it is not possible to tunnel a TLS connection inside a TLS tunnel.

+
+
tls_opts ([])
+

Options to use for tunneled TLS connections.

+
+
tls_handshake_timeout (infinity)
+

Handshake timeout for tunneled TLS connections.

+
+
+

http_opts()

+
+
http_opts() :: #{
+    keepalive             => timeout(),
+    transform_header_name => fun((binary()) -> binary()),
+    version               => 'HTTP/1.1' | 'HTTP/1.0'
+}
+
+

Configuration for the HTTP protocol.

+

The default value is given next to the option name:

+ +
keepalive (5000)
+

Time between pings in milliseconds. Since the HTTP protocol has no standardized way to ping the server, Gun will simply send an empty line when the connection is idle. Gun only makes a best effort here as servers usually have configurable limits to drop idle connections. Use infinity to disable.

+
+
transform_header_name - see below
+

A function that will be applied to all header names before they are sent to the server. Gun assumes that all header names are in lower case. This function is useful if you, for example, need to re-case header names in the event that the server incorrectly considers the case of header names to be significant.

+
+
version ('HTTP/1.1')
+

HTTP version to use.

+
+
+

http2_opts()

+
+
http2_opts() :: #{
+    keepalive => timeout()
+}
+
+

Configuration for the HTTP/2 protocol.

+

The default value is given next to the option name:

+ +
keepalive (5000)
+

Time between pings in milliseconds.

+
+
+ +

opts()

+
+
opts() :: #{
+    connect_timeout => timeout(),
+    http_opts       => http_opts(),
+    http2_opts      => http2_opts(),
+    protocols       => [http | http2],
+    retry           => non_neg_integer(),
+    retry_timeout   => pos_integer(),
+    trace           => boolean(),
+    transport       => tcp | tls,
+    transport_opts  => [gen_tcp:connect_option()] | [ssl:connect_option()],
+    ws_opts         => ws_opts()
+}
+
+

Configuration for the connection.

+

The default value is given next to the option name:

+
connect_timeout (infinity)
+

Connection timeout.

+
+
http_opts (#{})
+

Options specific to the HTTP protocol.

+
+
http2_opts (#{})
+

Options specific to the HTTP/2 protocol.

+
+
protocols - see below
+

Ordered list of preferred protocols. When the transport is tcp, this list must contain exactly one protocol. When the transport is tls, this list must contain at least one protocol and will be used to negotiate a protocol via ALPN. When the server does not support ALPN then http will always be used. Defaults to [http] when the transport is tcp, and [http2, http] when the transport is tls.

+
+
retry (5)
+

Number of times Gun will try to reconnect on failure before giving up.

+
+
retry_timeout (5000)
+

Time between retries in milliseconds.

+
+
trace (false)
+

Whether to enable dbg tracing of the connection process. Should only be used during debugging.

+
+
transport - see below
+

Whether to use TLS or plain TCP. The default varies depending on the port used. Port 443 defaults to tls. All other ports default to tcp.

+
+
transport_opts ([])
+

Transport options. They are TCP options or TLS options depending on the selected transport.

+
+
ws_opts (#{})
+

Options specific to the Websocket protocol.

+
+
+

req_opts()

+
+
req_opts() :: #{
+    reply_to => pid()
+}
+
+

Configuration for a particular request.

+

The default value is given next to the option name:

+
reply_to (self())
+

The pid of the process that will receive the response messages.

+
+
+

ws_opts()

+
+
ws_opts() :: #{
+    compress => boolean()
+}
+
+

Configuration for the Websocket protocol.

+

The default value is given next to the option name:

+
compress => boolean()
+

Whether to enable permessage-deflate compression. This does not guarantee that compression will be used as it is the server that ultimately decides. Defaults to false.

+
+
+ +

Changelog

+
  • 1.2: Introduce the type connect_destination(). +
  • +
+

See also

+

gun(7)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun_app/index.html b/docs/en/gun/1.2/manual/gun_app/index.html new file mode 100644 index 00000000..6ec8ad7b --- /dev/null +++ b/docs/en/gun/1.2/manual/gun_app/index.html @@ -0,0 +1,163 @@ + + + + + + + + + + Nine Nines: gun(7) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun(7)

+ +

Name

+

gun - HTTP/1.1, HTTP/2 and Websocket client for Erlang/OTP

+

Description

+

Gun is an HTTP client for Erlang/OTP with support for the HTTP/1.1, HTTP/2 and Websocket protocols.

+

Gun aims to provide an easy to use, asynchronous and always-connected client. It maintains a permanent connection to the server and reconnects automatically when necessary.

+

Modules

+
  • gun(3) - Asynchronous HTTP client +
  • +
+

Dependencies

+
  • cowlib(7) - Support library for manipulating Web protocols +
  • +
  • ssl - Secure communication over sockets +
  • +
+

All these applications must be started before the gun application. To start Gun and all dependencies at once:

+
+
{ok, _} = application:ensure_all_started(gun).
+
+

Environment

+

The gun application does not define any application environment configuration parameters.

+

See also

+

cowlib(7)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun_data/index.html b/docs/en/gun/1.2/manual/gun_data/index.html new file mode 100644 index 00000000..43ac5bd3 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun_data/index.html @@ -0,0 +1,187 @@ + + + + + + + + + + Nine Nines: gun_data(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun_data(3)

+ +

Name

+

gun_data - Response body

+

Description

+
+
{gun_data, ConnPid, StreamRef, IsFin, Data}
+
+ConnPid   :: pid()
+StreamRef :: reference()
+IsFin     :: fin | nofin
+Data      :: binary()
+
+

Response body.

+

This message informs the relevant process that the server sent a all or part of the body for the response to the original request.

+

A data message is always preceded by a response message.

+

The response body may be terminated either by a data message with the flag fin set or by a gun_trailers(3) message.

+

Elements

+
ConnPid
+

The pid of the Gun connection process.

+
+
StreamRef
+

Identifier of the stream for the original request.

+
+
IsFin
+

Whether this message terminates the response.

+
+
Data
+

All or part of the response body.

+
+
+

Changelog

+
  • 1.0: Message introduced. +
  • +
+

Examples

+
Receive a gun_data message in a gen_server
+
+
handle_info({gun_data, ConnPid, _StreamRef,
+             _IsFin, _Data},
+            State=#state{conn_pid=ConnPid}) ->
+    %% Do something.
+    {noreply, State}.
+
+

See also

+

gun(3), gun:get(3), gun:head(3), gun:patch(3), gun:post(3), gun:put(3), gun:delete(3), gun:options(3), gun:request(3), gun_response(3), gun_trailers(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun_down/index.html b/docs/en/gun/1.2/manual/gun_down/index.html new file mode 100644 index 00000000..a180670b --- /dev/null +++ b/docs/en/gun/1.2/manual/gun_down/index.html @@ -0,0 +1,193 @@ + + + + + + + + + + Nine Nines: gun_down(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun_down(3)

+ +

Name

+

gun_down - The connection is down

+

Description

+
+
{gun_down, ConnPid, Protocol, Reason, KilledStreams, UnprocessedStreams}
+
+ConnPid            :: pid()
+Protocol           :: http | http2 | ws
+Reason             :: any()
+KilledStreams      :: [reference()]
+UnprocessedStreams :: [reference()]
+
+

The connection is down.

+

This message informs the owner process that the connection was lost. Depending on the retry and retry_timeout options Gun may automatically attempt to reconnect.

+

When the connection goes back up, Gun will not attempt to retry requests. It will also not upgrade to Websocket automatically if that was the protocol in use when the connection was lost.

+

Elements

+
ConnPid
+

The pid of the Gun connection process.

+
+
Protocol
+

The protocol that was selected for this connection or upgraded to during the course of the connection.

+
+
Reason
+

The reason for the loss of the connection.

+

It is present for debugging purposes only. You should not rely on this value to perform operations programmatically.

+
+
KilledStreams
+

List of streams that have been brutally terminated.

+

They are active streams that did not complete before the closing of the connection. Whether they can be retried safely depends on the protocol used and the idempotence property of the requests.

+
+
UnprocessedStreams
+

List of streams that have not been processed by the server.

+

They are streams that the server did not start processing yet. They may be retried safely depending on whether related streams were killed.

+
+
+

Changelog

+
  • 1.0: Message introduced. +
  • +
+

Examples

+
Receive a gun_down message in a gen_server
+
+
handle_info({gun_down, ConnPid, _Protocol,
+             _Reason, _Killed, _Unprocessed},
+            State=#state{conn_pid=ConnPid}) ->
+    %% Do something.
+    {noreply, State}.
+
+

See also

+

gun(3), gun:open(3), gun:open_unix(3), gun_up(3), gun_error(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun_error/index.html b/docs/en/gun/1.2/manual/gun_error/index.html new file mode 100644 index 00000000..3eb54a5f --- /dev/null +++ b/docs/en/gun/1.2/manual/gun_error/index.html @@ -0,0 +1,186 @@ + + + + + + + + + + Nine Nines: gun_error(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun_error(3)

+ +

Name

+

gun_error - Stream or connection-wide error

+

Description

+
+
{gun_error, ConnPid, StreamRef, Reason}
+{gun_error, ConnPid, Reason}
+
+ConnPid   :: pid()
+StreamRef :: reference()
+Reason    :: any()
+
+

Stream or connection-wide error.

+

These messages inform the relevant process that an error occurred. A reference is given when the error pertains to a specific stream. Connection-wide errors do not imply that the connection is no longer usable, they are used for all errors that are not specific to a stream.

+

Elements

+
ConnPid
+

The pid of the Gun connection process.

+
+
StreamRef
+

Identifier of the stream that resulted in an error.

+
+
Reason
+

The reason for the error.

+

It is present for debugging purposes only. You should not rely on this value to perform operations programmatically.

+
+
+

Changelog

+
  • 1.0: Message introduced. +
  • +
+

Examples

+
Receive a gun_error message in a gen_server
+
+
handle_info({gun_error, ConnPid, _Reason},
+            State=#state{conn_pid=ConnPid}) ->
+    %% Do something.
+    {noreply, State};
+handle_info({gun_error, ConnPid, _StreamRef, _Reason},
+            State=#state{conn_pid=ConnPid}) ->
+    %% Do something.
+    {noreply, State}.
+
+

See also

+

gun(3), gun_up(3), gun_down(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun_inform/index.html b/docs/en/gun/1.2/manual/gun_inform/index.html new file mode 100644 index 00000000..7524de76 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun_inform/index.html @@ -0,0 +1,186 @@ + + + + + + + + + + Nine Nines: gun_inform(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun_inform(3)

+ +

Name

+

gun_inform - Informational response

+

Description

+
+
{gun_inform, ConnPid, StreamRef, Status, Headers}
+
+ConnPid   :: pid()
+StreamRef :: reference()
+Status    :: 100..199
+Headers   :: [{binary(), binary()}]
+
+

Informational response.

+

This message informs the relevant process that the server sent an informational response to the original request.

+

Informational responses are only intermediate responses and provide no guarantees as to what the final response will be. An informational response always precedes the response to the original request.

+

Elements

+
ConnPid
+

The pid of the Gun connection process.

+
+
StreamRef
+

Identifier of the stream for the original request.

+
+
Status
+

Status code for the informational response.

+
+
Headers
+

Headers sent with the informational response.

+
+
+

Changelog

+
  • 1.0: Message introduced. +
  • +
+

Examples

+
Receive a gun_inform message in a gen_server
+
+
handle_info({gun_inform, ConnPid, _StreamRef,
+             _Status, _Headers},
+            State=#state{conn_pid=ConnPid}) ->
+    %% Do something.
+    {noreply, State}.
+
+

See also

+

gun(3), gun:get(3), gun:patch(3), gun:post(3), gun:put(3), gun_response(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun_push/index.html b/docs/en/gun/1.2/manual/gun_push/index.html new file mode 100644 index 00000000..12d552b9 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun_push/index.html @@ -0,0 +1,206 @@ + + + + + + + + + + Nine Nines: gun_push(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun_push(3)

+ +

Name

+

gun_push - Server-initiated push

+

Description

+
+
{gun_push, ConnPid, StreamRef, NewStreamRef, Method, URI, Headers}
+
+ConnPid      :: pid()
+StreamRef    :: reference()
+NewStreamRef :: reference()
+Method       :: binary()
+URI          :: binary()
+Headers      :: [{binary(), binary()}]
+
+

Server-initiated push.

+

This message informs the relevant process that the server is pushing a resource related to the effective target URI of the original request.

+

A server-initiated push message always precedes the response to the original request.

+

This message will not be sent when using the HTTP/1.1 protocol because it lacks the concept of server-initiated push.

+

Elements

+
ConnPid
+

The pid of the Gun connection process.

+
+
StreamRef
+

Identifier of the stream for the original request.

+
+
NewStreamRef
+

Identifier of the stream being pushed.

+
+
Method
+

Method of the equivalent HTTP request.

+
+
URI
+

URI of the resource being pushed.

+
+
Headers
+

Headers of the equivalent HTTP request.

+
+
+

Changelog

+
  • 1.0: Message introduced. +
  • +
+

Examples

+
Receive a gun_push message in a gen_server
+
+
handle_info({gun_push, ConnPid, _StreamRef,
+             _NewStreamRef, _Method, _URI, _Headers},
+            State=#state{conn_pid=ConnPid}) ->
+    %% Do something.
+    {noreply, State}.
+
+
Cancel an unwanted push
+
+
handle_info({gun_push, ConnPid, _StreamRef,
+             NewStreamRef, _Method, _URI, _Headers},
+            State=#state{conn_pid=ConnPid}) ->
+    gun:cancel(ConnPid, NewStreamRef),
+    {noreply, State}.
+
+

See also

+

gun(3), gun:get(3), gun:cancel(3), gun_response(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun_response/index.html b/docs/en/gun/1.2/manual/gun_response/index.html new file mode 100644 index 00000000..6a7140b9 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun_response/index.html @@ -0,0 +1,189 @@ + + + + + + + + + + Nine Nines: gun_response(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun_response(3)

+ +

Name

+

gun_response - Response

+

Description

+
+
{gun_response, ConnPid, StreamRef, IsFin, Status, Headers}
+
+ConnPid   :: pid()
+StreamRef :: reference()
+IsFin     :: fin | nofin
+Status    :: non_neg_integer()
+Headers   :: [{binary(), binary()}]
+
+

Response.

+

This message informs the relevant process that the server sent a response to the original request.

+

Elements

+
ConnPid
+

The pid of the Gun connection process.

+
+
StreamRef
+

Identifier of the stream for the original request.

+
+
IsFin
+

Whether this message terminates the response.

+
+
Status
+

Status code for the response.

+
+
Headers
+

Headers sent with the response.

+
+
+

Changelog

+
  • 1.0: Message introduced. +
  • +
+

Examples

+
Receive a gun_response message in a gen_server
+
+
handle_info({gun_response, ConnPid, _StreamRef,
+             _IsFin, _Status, _Headers},
+            State=#state{conn_pid=ConnPid}) ->
+    %% Do something.
+    {noreply, State}.
+
+

See also

+

gun(3), gun:get(3), gun:head(3), gun:patch(3), gun:post(3), gun:put(3), gun:delete(3), gun:options(3), gun:request(3), gun_inform(3), gun_push(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun_trailers/index.html b/docs/en/gun/1.2/manual/gun_trailers/index.html new file mode 100644 index 00000000..117ff514 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun_trailers/index.html @@ -0,0 +1,181 @@ + + + + + + + + + + Nine Nines: gun_trailers(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun_trailers(3)

+ +

Name

+

gun_trailers - Response trailers

+

Description

+
+
{gun_trailers, ConnPid, StreamRef, Headers}
+
+ConnPid   :: pid()
+StreamRef :: reference()
+Headers   :: [{binary(), binary()}]
+
+

Response trailers.

+

This message informs the relevant process that the server sent response trailers for the response to the original request.

+

A trailers message terminates the response.

+

Elements

+
ConnPid
+

The pid of the Gun connection process.

+
+
StreamRef
+

Identifier of the stream for the original request.

+
+
Headers
+

Trailing headers sent after the response body.

+
+
+

Changelog

+
  • 1.0: Message introduced. +
  • +
+

Examples

+
Receive a gun_trailers message in a gen_server
+
+
handle_info({gun_trailers, ConnPid, _StreamRef, _Headers},
+            State=#state{conn_pid=ConnPid}) ->
+    %% Do something.
+    {noreply, State}.
+
+

See also

+

gun(3), gun:get(3), gun:head(3), gun:patch(3), gun:post(3), gun:put(3), gun:delete(3), gun:options(3), gun:request(3), gun_response(3), gun_data(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun_up/index.html b/docs/en/gun/1.2/manual/gun_up/index.html new file mode 100644 index 00000000..81389314 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun_up/index.html @@ -0,0 +1,177 @@ + + + + + + + + + + Nine Nines: gun_up(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun_up(3)

+ +

Name

+

gun_up - The connection is up

+

Description

+
+
{gun_up, ConnPid, Protocol}
+
+ConnPid  :: pid()
+Protocol :: http | http2
+
+

The connection is up.

+

This message informs the owner process that the connection or reconnection completed.

+

Gun will now start processing the messages it received while waiting for the connection to be up. If this is a reconnection, then this may not be desirable for all requests. Those requests should be cancelled when the connection goes down, and any subsequent messages ignored.

+

Elements

+
ConnPid
+

The pid of the Gun connection process.

+
+
Protocol
+

The protocol selected for this connection. It can be used to determine the capabilities of the server.

+
+
+

Changelog

+
  • 1.0: Message introduced. +
  • +
+

Examples

+
Receive a gun_up message in a gen_server
+
+
handle_info({gun_up, ConnPid, _Protocol},
+            State=#state{conn_pid=ConnPid}) ->
+    %% Do something.
+    {noreply, State}.
+
+

See also

+

gun(3), gun:open(3), gun:open_unix(3), gun:await_up(3), gun_down(3), gun_error(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun_upgrade/index.html b/docs/en/gun/1.2/manual/gun_upgrade/index.html new file mode 100644 index 00000000..745983b2 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun_upgrade/index.html @@ -0,0 +1,187 @@ + + + + + + + + + + Nine Nines: gun_upgrade(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun_upgrade(3)

+ +

Name

+

gun_upgrade - Successful protocol upgrade

+

Description

+
+
{gun_upgrade, ConnPid, StreamRef, Protocols, Headers}
+
+ConnPid   :: pid()
+StreamRef :: reference()
+Protocols :: [<<"websocket">>]
+Headers   :: [{binary(), binary()}]
+
+

Successful protocol upgrade.

+

This message informs the relevant process that the server accepted to upgrade to one or more protocols given in the original request.

+

The exact semantics of this message depend on the original protocol. HTTP/1.1 upgrades apply to the entire connection. HTTP/2 uses a different mechanism which allows switching specific streams to a different protocol.

+

Gun currently only supports upgrading HTTP/1.1 connections to the Websocket protocol.

+

Elements

+
ConnPid
+

The pid of the Gun connection process.

+
+
StreamRef
+

Identifier of the stream that resulted in an upgrade.

+
+
Protocols
+

List of protocols this stream was upgraded to.

+
+
Headers
+

Headers sent with the upgrade response.

+
+
+

Changelog

+
  • 1.0: Message introduced. +
  • +
+

Examples

+
Receive a gun_upgrade message in a gen_server
+
+
handle_info({gun_upgrade, ConnPid, _StreamRef,
+             _Protocols, _Headers},
+            State=#state{conn_pid=ConnPid}) ->
+    %% Do something.
+    {noreply, State}.
+
+

See also

+

gun(3), gun:ws_upgrade(3), gun:ws_send(3), gun_ws(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/gun_ws/index.html b/docs/en/gun/1.2/manual/gun_ws/index.html new file mode 100644 index 00000000..dec115a7 --- /dev/null +++ b/docs/en/gun/1.2/manual/gun_ws/index.html @@ -0,0 +1,183 @@ + + + + + + + + + + Nine Nines: gun_ws(3) + + + + + + + + + + + + + + + + +
+
+
+
+ +

gun_ws(3)

+ +

Name

+

gun_ws - Websocket frame

+

Description

+
+
{gun_ws, ConnPid, StreamRef, Frame}
+
+ConnPid   :: pid()
+StreamRef :: reference()
+Frame     :: close
+           | {text | binary | close, binary()}
+           | {close, non_neg_integer(), binary()}
+
+

Websocket frame.

+

This message informs the relevant process that the server sent the enclosed frame.

+

This message can only be sent on streams that were upgraded to the Websocket protocol.

+

Elements

+
ConnPid
+

The pid of the Gun connection process.

+
+
StreamRef
+

Identifier of the stream that was upgraded to Websocket.

+
+
Frame
+

The Websocket frame in question.

+
+
+

Changelog

+
  • 1.0: Message introduced. +
  • +
+

Examples

+
Receive a gun_ws message in a gen_server
+
+
handle_info({gun_ws, ConnPid, _StreamRef, _Frame},
+            State=#state{conn_pid=ConnPid}) ->
+    %% Do something.
+    {noreply, State}.
+
+

See also

+

gun(3), gun:ws_upgrade(3), gun:ws_send(3), gun_upgrade(3)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

+ + +
+
+
+
+ + + + + + + + + diff --git a/docs/en/gun/1.2/manual/index.html b/docs/en/gun/1.2/manual/index.html new file mode 100644 index 00000000..311b0850 --- /dev/null +++ b/docs/en/gun/1.2/manual/index.html @@ -0,0 +1,163 @@ + + + + + + + + + + Nine Nines: Gun Function Reference + + + + + + + + + + + + + + + + +
+
+
+
+ +

Gun Function Reference

+ +

Name

+

gun - HTTP/1.1, HTTP/2 and Websocket client for Erlang/OTP

+

Description

+

Gun is an HTTP client for Erlang/OTP with support for the HTTP/1.1, HTTP/2 and Websocket protocols.

+

Gun aims to provide an easy to use, asynchronous and always-connected client. It maintains a permanent connection to the server and reconnects automatically when necessary.

+

Modules

+
  • gun(3) - Asynchronous HTTP client +
  • +
+

Dependencies

+
  • cowlib(7) - Support library for manipulating Web protocols +
  • +
  • ssl - Secure communication over sockets +
  • +
+

All these applications must be started before the gun application. To start Gun and all dependencies at once:

+
+
{ok, _} = application:ensure_all_started(gun).
+
+

Environment

+

The gun application does not define any application environment configuration parameters.

+

See also

+

cowlib(7)

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

+ Gun + 1.2 + Function Reference + +

+ + + +

Navigation

+ +

Version select

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