Skip to content

Commit 6047d27

Browse files
authored
Merge pull request #86 from nagamoto/feature/add_net_open_timeout_option
Feature/add net open timeout option
2 parents 2ce2a1c + c7a7112 commit 6047d27

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/line/bot/client.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class Client
2727
# @return [Object]
2828
attr_accessor :httpclient
2929

30+
# @return [Hash]
31+
attr_accessor :http_options
32+
3033
# Initialize a new Bot Client.
3134
#
3235
# @param options [Hash]
@@ -40,7 +43,7 @@ def initialize(options = {})
4043
end
4144

4245
def httpclient
43-
@httpclient ||= Line::Bot::HTTPClient.new
46+
@httpclient ||= Line::Bot::HTTPClient.new(http_options)
4447
end
4548

4649
def endpoint

lib/line/bot/httpclient.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,31 @@
2020
module Line
2121
module Bot
2222
class HTTPClient
23+
# @return [Hash]
24+
attr_accessor :http_options
25+
26+
# Initialize a new HTTPClient
27+
#
28+
# @param http_options [Hash]
29+
#
30+
# @return [Line::Bot::HTTPClient]
31+
def initialize(http_options = {})
32+
@http_options = http_options
33+
end
34+
2335
# @return [Net::HTTP]
2436
def http(uri)
2537
http = Net::HTTP.new(uri.host, uri.port)
2638
if uri.scheme == "https"
2739
http.use_ssl = true
2840
end
2941

42+
if http_options
43+
http_options.each do |key, value|
44+
http.send("#{key}=", value)
45+
end
46+
end
47+
3048
http
3149
end
3250

0 commit comments

Comments
 (0)