Skip to content

Commit

Permalink
add http timeout options
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr Borisov committed Apr 25, 2018
1 parent 412b228 commit 750d03f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ post "/push" do
subject: "mailto:[email protected]",
public_key: ENV['VAPID_PUBLIC_KEY'],
private_key: ENV['VAPID_PRIVATE_KEY']
}
},
ssl_timeout: 5, # value for Net::HTTP#ssl_timeout=, optional
open_timeout: 5, # value for Net::HTTP#open_timeout=, optional
read_timeout: 5 # value for Net::HTTP#read_timeout=, optional
)
end
```
Expand Down
4 changes: 4 additions & 0 deletions lib/webpush/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def initialize(message: "", subscription:, vapid:, **options)
def perform
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.ssl_timeout = @options[:ssl_timeout] unless @options[:ssl_timeout].nil?
http.open_timeout = @options[:open_timeout] unless @options[:open_timeout].nil?
http.read_timeout = @options[:read_timeout] unless @options[:read_timeout].nil?

req = Net::HTTP::Post.new(uri.request_uri, headers)
req.body = body
resp = http.request(req)
Expand Down

0 comments on commit 750d03f

Please sign in to comment.