aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2014-03-26 18:36:56 +0100
committerLoïc Hoguin <[email protected]>2014-03-26 18:36:56 +0100
commit060cbb52a5cea22c7b0e83d819a31a41e17456fd (patch)
treebb577ebcb3543ed832791cdd80de3eaa859fbaa1
parentecc4f153cd713562c4d7b54ece0e274a411fd26f (diff)
downloadgun-060cbb52a5cea22c7b0e83d819a31a41e17456fd.tar.gz
gun-060cbb52a5cea22c7b0e83d819a31a41e17456fd.tar.bz2
gun-060cbb52a5cea22c7b0e83d819a31a41e17456fd.zip
Default to TCP if port 80 is given, otherwise SSL
-rw-r--r--src/gun.erl3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/gun.erl b/src/gun.erl
index e4a919d..8f056aa 100644
--- a/src/gun.erl
+++ b/src/gun.erl
@@ -378,7 +378,8 @@ init(Parent, Owner, Host, Port, Opts) ->
Keepalive = get_value(keepalive, Opts, 5000),
Retry = get_value(retry, Opts, 5),
RetryTimeout = get_value(retry_timeout, Opts, 5000),
- Type = get_value(type, Opts, ssl),
+ %% Default to TCP if port 80 is given, otherwise SSL.
+ Type = get_value(type, Opts, if Port =:= 80 -> tcp; true -> ssl end),
connect(#state{parent=Parent, owner=Owner, host=Host, port=Port,
keepalive=Keepalive, type=Type, retry=Retry,
proto_opts=HTTPOpts, retry_timeout=RetryTimeout}, Retry).