aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-08-26 19:08:38 +0200
committerLoïc Hoguin <[email protected]>2013-08-26 19:08:38 +0200
commit5347bd3335f45f244f82e5f10da3993d9fdc56a3 (patch)
tree28f79c3d5554ef2cb898dfe8cd751a63a62cb2c5
parente176953cd095e8c65d56461f840a14d53c57a1c1 (diff)
downloadgun-5347bd3335f45f244f82e5f10da3993d9fdc56a3.tar.gz
gun-5347bd3335f45f244f82e5f10da3993d9fdc56a3.tar.bz2
gun-5347bd3335f45f244f82e5f10da3993d9fdc56a3.zip
Add gun:open/2
-rw-r--r--guide/connect.md14
-rw-r--r--src/gun.erl4
-rw-r--r--test/twitter_SUITE.erl2
3 files changed, 13 insertions, 7 deletions
diff --git a/guide/connect.md b/guide/connect.md
index 147edf3..5655d66 100644
--- a/guide/connect.md
+++ b/guide/connect.md
@@ -13,16 +13,18 @@ server. Because of this, the connection must be initiated
before being able to send any request.
The process that creates the connection is also known as the
-owner of the connection. Only this process can perform operations
-on the connection, and only this process will receive messages
-from the connection.
+owner of the connection, or the controlling process.. Only
+this process can perform operations on the connection, and
+only this process will receive messages from the connection.
-To open a new connection, the `gun:open/3` function can be used.
+To open a new connection, the `gun:open/{2,3}` function can be used.
``` erlang
-{ok, Pid} = gun:open("twitter.com", 443, []).
+{ok, Pid} = gun:open("twitter.com", 443).
```
+Gun will by default assume that SSL should be used.
+
The connection is managed by a separate process and is supervised
by the Gun supervisor directly.
@@ -41,7 +43,7 @@ nature of Gun, we only need to create a monitor once when
the connection is established.
``` erlang
-{ok, Pid} = gun:open("twitter.com", 443, []).
+{ok, Pid} = gun:open("twitter.com", 443).
MRef = monitor(process, Pid).
```
diff --git a/src/gun.erl b/src/gun.erl
index 112ab07..001d332 100644
--- a/src/gun.erl
+++ b/src/gun.erl
@@ -15,6 +15,7 @@
-module(gun).
%% Connection.
+-export([open/2]).
-export([open/3]).
-export([close/1]).
-export([shutdown/1]).
@@ -69,6 +70,9 @@
%% Connection.
+open(Host, Port) ->
+ open(Host, Port, []).
+
open(Host, Port, Opts) ->
case open_opts(Opts) of
ok ->
diff --git a/test/twitter_SUITE.erl b/test/twitter_SUITE.erl
index ba3f949..ad698a3 100644
--- a/test/twitter_SUITE.erl
+++ b/test/twitter_SUITE.erl
@@ -48,7 +48,7 @@ end_per_suite(_) ->
ok.
spdy(_) ->
- {ok, Pid} = gun:open("twitter.com", 443, []),
+ {ok, Pid} = gun:open("twitter.com", 443),
Ref = gun:get(Pid, "/"),
receive
{gun_response, Pid, Ref, Status, Headers} ->