aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-04-10 16:34:21 +0300
committerLoïc Hoguin <[email protected]>2015-04-10 16:34:21 +0300
commitcff0a87d3cbdcf67a9049cdc2784d459711e2867 (patch)
tree6eabc302b146843e8d00bd761be41b32d8f478d3 /doc
parentc46991067a53c81316a69c1df7c7dc590f3ca308 (diff)
downloadgun-cff0a87d3cbdcf67a9049cdc2784d459711e2867.tar.gz
gun-cff0a87d3cbdcf67a9049cdc2784d459711e2867.tar.bz2
gun-cff0a87d3cbdcf67a9049cdc2784d459711e2867.zip
Add Websocket options
Allow passing Websocket options through either open or ws_upgrade. Document ws_upgrade/4.
Diffstat (limited to 'doc')
-rw-r--r--doc/src/guide/websocket.asciidoc8
-rw-r--r--doc/src/manual/gun.asciidoc18
2 files changed, 18 insertions, 8 deletions
diff --git a/doc/src/guide/websocket.asciidoc b/doc/src/guide/websocket.asciidoc
index 23c5030..83a8384 100644
--- a/doc/src/guide/websocket.asciidoc
+++ b/doc/src/guide/websocket.asciidoc
@@ -14,7 +14,7 @@ HTTP/1.1 connections can be upgraded to Websocket, so you might
need to restrict the protocol to HTTP/1.1 if you are planning
to use Websocket over TLS.
-You must use the `gun_ws:upgrade/{2,3}` function to upgrade
+You must use the `gun_ws:upgrade/{2,3,4}` function to upgrade
to Websocket. This function can be called anytime after connection,
so you can send HTTP requests before upgrading to Websocket.
@@ -34,6 +34,12 @@ gun:ws_upgrade(ConnPid, "/websocket", [
{<<"sec-websocket-protocol">>, "mychat"}
]).
+You can pass the Websocket options as part of the `gun:open/{2,3}`
+call when opening the connection, or using the `gun:ws_upgrade/4`.
+The fourth argument is those same options. This function call
+will crash if the options are incorrect, unlike when passing
+them through `gun:open/{2,3}`.
+
The success or failure of this operation will be sent as a
message.
diff --git a/doc/src/manual/gun.asciidoc b/doc/src/manual/gun.asciidoc
index fb457a4..7c12fc3 100644
--- a/doc/src/manual/gun.asciidoc
+++ b/doc/src/manual/gun.asciidoc
@@ -18,7 +18,7 @@ Configuration for the connection.
The following keys are defined:
-http_opts => gun:http_opts()::
+http_opts => http_opts()::
Options specific to the HTTP protocol. See below.
protocols => [http | spdy]::
Ordered list of preferred protocols. When the transport is tcp,
@@ -33,7 +33,7 @@ retry => non_neg_integer()::
Defaults to 5.
retry_timeout => pos_integer()::
Time between retries in milliseconds. Defaults to 5000.
-spdy_opts => gun:spdy_opts()::
+spdy_opts => spdy_opts()::
Options specific to the SPDY protocol. See below.
trace => boolean()::
Whether to enable `dbg` tracing of the connection process. Should
@@ -44,6 +44,8 @@ transport => tcp | ssl::
transport_opts => proplists:proplist()::
Transport options. They are TCP options or SSL options depending on
the selected transport.
+ws_opts => ws_opts()::
+ Options specific to the Websocket protocol. See below.
=== http_opts() = map()
@@ -640,18 +642,20 @@ SPDY streams can however be cancelled at any time.
=== ws_upgrade(ConnPid, Path) -> ws_upgrade(ConnPid, Path, [], #{})
-Alias of `gun:ws_upgrade/4`.
+Alias of `gun:ws_upgrade/3`.
-=== ws_upgrade(ConnPid, Path, Headers) -> ws_upgrade(ConnPid, Path, Headers, #{})
+=== ws_upgrade(ConnPid, Path, Headers) -> ok
-Alias of `gun:ws_upgrade/4`.
+Similar to `gun:ws_upgrade/4`, except `WsOpts` is taken from
+the options given in the `gun:open/{2,3}` call when opening
+the connection.
-=== ws_upgrade(ConnPid, Path, Headers, Opts) -> ok
+=== ws_upgrade(ConnPid, Path, Headers, WsOpts) -> ok
ConnPid = pid():: The pid of the Gun connection process.
Path = iodata():: Path to the resource.
Headers = [{binary(), iodata()}]:: Additional request headers.
-Opts = map():: Options for the Websocket connection.
+WsOpts = map():: Options for the Websocket connection.
Request the connection to be upgraded to the Websocket protocol.