lib/kotsms2/network.rb in kotsms2-1.0.1 vs lib/kotsms2/network.rb in kotsms2-1.1.0
- old
+ new
@@ -19,18 +19,23 @@
http_response.body
when Net::HTTPClientError
raise ClientError, "#{http_response.code} response from #{host}"
when Net::HTTPServerError
raise ServerError, "#{http_response.code} response from #{host}"
+ when 'READ_TIMEOUT'
+ raise ClientTimeoutError, "Read Timeout from #{host}"
else
raise Error, "#{http_response.code} response from #{host}"
end
end
def request(uri, message)
http = Net::HTTP.new(uri.host, Net::HTTP.https_default_port)
+ http.read_timeout = @timeout
http.use_ssl = true
http.request(message)
+ rescue Net::ReadTimeout
+ 'READ_TIMEOUT'
end
def query_string(params)
params.flat_map { |k, vs| Array(vs).map { |v| "#{escape(k)}=#{escape(v)}" } }.join('&')
end
\ No newline at end of file