diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gun.erl | 5 | ||||
-rw-r--r-- | src/gun_http.erl | 2 | ||||
-rw-r--r-- | src/gun_http2.erl | 2 |
3 files changed, 8 insertions, 1 deletions
diff --git a/src/gun.erl b/src/gun.erl index 4857344..e9155b2 100644 --- a/src/gun.erl +++ b/src/gun.erl @@ -624,7 +624,10 @@ before_loop(State=#state{opts=Opts, protocol=Protocol}) -> end, ProtoOpts = maps:get(ProtoOptsKey, Opts, #{}), Keepalive = maps:get(keepalive, ProtoOpts, 5000), - KeepaliveRef = erlang:send_after(Keepalive, self(), keepalive), + KeepaliveRef = case Keepalive of + infinity -> undefined; + _ -> erlang:send_after(Keepalive, self(), keepalive) + end, loop(State#state{keepalive_ref=KeepaliveRef}). loop(State=#state{parent=Parent, owner=Owner, owner_ref=OwnerRef, host=Host, port=Port, opts=Opts, diff --git a/src/gun_http.erl b/src/gun_http.erl index 3766ca5..204ce4a 100644 --- a/src/gun_http.erl +++ b/src/gun_http.erl @@ -60,6 +60,8 @@ check_options(Opts) -> do_check_options([]) -> ok; +do_check_options([{keepalive, infinity}|Opts]) -> + do_check_options(Opts); do_check_options([{keepalive, K}|Opts]) when is_integer(K), K > 0 -> do_check_options(Opts); do_check_options([{version, V}|Opts]) when V =:= 'HTTP/1.1'; V =:= 'HTTP/1.0' -> diff --git a/src/gun_http2.erl b/src/gun_http2.erl index 4e108ae..38017b3 100644 --- a/src/gun_http2.erl +++ b/src/gun_http2.erl @@ -74,6 +74,8 @@ check_options(Opts) -> do_check_options([]) -> ok; +do_check_options([{keepalive, infinity}|Opts]) -> + do_check_options(Opts); do_check_options([{keepalive, K}|Opts]) when is_integer(K), K > 0 -> do_check_options(Opts); do_check_options([Opt={content_handlers, Handlers}|Opts]) -> |