net-http 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.document +4 -0
- data/lib/net/http/exceptions.rb +2 -1
- data/lib/net/http/generic_request.rb +5 -6
- data/lib/net/http/header.rb +8 -4
- data/lib/net/http/requests.rb +15 -1
- data/lib/net/http/response.rb +2 -1
- data/lib/net/http/responses.rb +68 -0
- data/lib/net/http.rb +57 -24
- metadata +5 -9
- data/Gemfile +0 -8
- data/Rakefile +0 -10
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/net-http.gemspec +0 -40
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6aa488199745a574db471b279c8cbb4b46cd5dded0308bd5888f0cd9c08d5102
|
|
4
|
+
data.tar.gz: d9804849a6cff66145baf7d6557ca5845ba8777d08acf940e431b11a8c5266d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d06f7fe540c1fae1b1d73b6b029c6e9b176073cdcf267b5b6b5b98095dd14d9cf53fd406b7cb1d854dbf9e31a8ff52fde927442f6f8250194df4166a00476e59
|
|
7
|
+
data.tar.gz: 3583aa361d6c121814bf3092cd1c314943774009564603452d0b0f17d9f0f35b3a7841ed02806fae131f0c85edc3dbcbe20938f010ac352fc267bfa4b36e0ebe
|
data/.document
ADDED
data/lib/net/http/exceptions.rb
CHANGED
|
@@ -3,7 +3,7 @@ module Net
|
|
|
3
3
|
# Net::HTTP exception class.
|
|
4
4
|
# You cannot use Net::HTTPExceptions directly; instead, you must use
|
|
5
5
|
# its subclasses.
|
|
6
|
-
module HTTPExceptions
|
|
6
|
+
module HTTPExceptions # :nodoc:
|
|
7
7
|
def initialize(msg, res) #:nodoc:
|
|
8
8
|
super msg
|
|
9
9
|
@response = res
|
|
@@ -12,6 +12,7 @@ module Net
|
|
|
12
12
|
alias data response #:nodoc: obsolete
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
# :stopdoc:
|
|
15
16
|
class HTTPError < ProtocolError
|
|
16
17
|
include HTTPExceptions
|
|
17
18
|
end
|
|
@@ -19,16 +19,13 @@ class Net::HTTPGenericRequest
|
|
|
19
19
|
|
|
20
20
|
if URI === uri_or_path then
|
|
21
21
|
raise ArgumentError, "not an HTTP URI" unless URI::HTTP === uri_or_path
|
|
22
|
-
hostname = uri_or_path.
|
|
22
|
+
hostname = uri_or_path.host
|
|
23
23
|
raise ArgumentError, "no host component for URI" unless (hostname && hostname.length > 0)
|
|
24
24
|
@uri = uri_or_path.dup
|
|
25
|
-
host = @uri.hostname.dup
|
|
26
|
-
host << ":" << @uri.port.to_s if @uri.port != @uri.default_port
|
|
27
25
|
@path = uri_or_path.request_uri
|
|
28
26
|
raise ArgumentError, "no HTTP request path given" unless @path
|
|
29
27
|
else
|
|
30
28
|
@uri = nil
|
|
31
|
-
host = nil
|
|
32
29
|
raise ArgumentError, "no HTTP request path given" unless uri_or_path
|
|
33
30
|
raise ArgumentError, "HTTP request path is empty" if uri_or_path.empty?
|
|
34
31
|
@path = uri_or_path.dup
|
|
@@ -51,7 +48,7 @@ class Net::HTTPGenericRequest
|
|
|
51
48
|
initialize_http_header initheader
|
|
52
49
|
self['Accept'] ||= '*/*'
|
|
53
50
|
self['User-Agent'] ||= 'Ruby'
|
|
54
|
-
self['Host'] ||=
|
|
51
|
+
self['Host'] ||= @uri.authority if @uri
|
|
55
52
|
@body = nil
|
|
56
53
|
@body_stream = nil
|
|
57
54
|
@body_data = nil
|
|
@@ -245,7 +242,7 @@ class Net::HTTPGenericRequest
|
|
|
245
242
|
end
|
|
246
243
|
|
|
247
244
|
if host = self['host']
|
|
248
|
-
host.
|
|
245
|
+
host = URI.parse("//#{host}").host # Remove a port component from the existing Host header
|
|
249
246
|
elsif host = @uri.host
|
|
250
247
|
else
|
|
251
248
|
host = addr
|
|
@@ -264,6 +261,8 @@ class Net::HTTPGenericRequest
|
|
|
264
261
|
|
|
265
262
|
private
|
|
266
263
|
|
|
264
|
+
# :stopdoc:
|
|
265
|
+
|
|
267
266
|
class Chunker #:nodoc:
|
|
268
267
|
def initialize(sock)
|
|
269
268
|
@sock = sock
|
data/lib/net/http/header.rb
CHANGED
|
@@ -179,7 +179,9 @@
|
|
|
179
179
|
# - #each_value: Passes each string field value to the block.
|
|
180
180
|
#
|
|
181
181
|
module Net::HTTPHeader
|
|
182
|
+
# The maximum length of HTTP header keys.
|
|
182
183
|
MAX_KEY_LENGTH = 1024
|
|
184
|
+
# The maximum length of HTTP header values.
|
|
183
185
|
MAX_FIELD_LENGTH = 65536
|
|
184
186
|
|
|
185
187
|
def initialize_http_header(initheader) #:nodoc:
|
|
@@ -267,6 +269,7 @@ module Net::HTTPHeader
|
|
|
267
269
|
end
|
|
268
270
|
end
|
|
269
271
|
|
|
272
|
+
# :stopdoc:
|
|
270
273
|
private def set_field(key, val)
|
|
271
274
|
case val
|
|
272
275
|
when Enumerable
|
|
@@ -294,6 +297,7 @@ module Net::HTTPHeader
|
|
|
294
297
|
ary.push val
|
|
295
298
|
end
|
|
296
299
|
end
|
|
300
|
+
# :startdoc:
|
|
297
301
|
|
|
298
302
|
# Returns the array field value for the given +key+,
|
|
299
303
|
# or +nil+ if there is no such field;
|
|
@@ -490,7 +494,7 @@ module Net::HTTPHeader
|
|
|
490
494
|
|
|
491
495
|
alias canonical_each each_capitalized
|
|
492
496
|
|
|
493
|
-
def capitalize(name)
|
|
497
|
+
def capitalize(name) # :nodoc:
|
|
494
498
|
name.to_s.split('-'.freeze).map {|s| s.capitalize }.join('-'.freeze)
|
|
495
499
|
end
|
|
496
500
|
private :capitalize
|
|
@@ -957,12 +961,12 @@ module Net::HTTPHeader
|
|
|
957
961
|
@header['proxy-authorization'] = [basic_encode(account, password)]
|
|
958
962
|
end
|
|
959
963
|
|
|
960
|
-
def basic_encode(account, password)
|
|
964
|
+
def basic_encode(account, password) # :nodoc:
|
|
961
965
|
'Basic ' + ["#{account}:#{password}"].pack('m0')
|
|
962
966
|
end
|
|
963
967
|
private :basic_encode
|
|
964
968
|
|
|
965
|
-
# Returns whether the HTTP session is to be closed.
|
|
969
|
+
# Returns whether the HTTP session is to be closed.
|
|
966
970
|
def connection_close?
|
|
967
971
|
token = /(?:\A|,)\s*close\s*(?:\z|,)/i
|
|
968
972
|
@header['connection']&.grep(token) {return true}
|
|
@@ -970,7 +974,7 @@ module Net::HTTPHeader
|
|
|
970
974
|
false
|
|
971
975
|
end
|
|
972
976
|
|
|
973
|
-
# Returns whether the HTTP session is to be kept alive.
|
|
977
|
+
# Returns whether the HTTP session is to be kept alive.
|
|
974
978
|
def connection_keep_alive?
|
|
975
979
|
token = /(?:\A|,)\s*keep-alive\s*(?:\z|,)/i
|
|
976
980
|
@header['connection']&.grep(token) {return true}
|
data/lib/net/http/requests.rb
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
# - Net::HTTP#get: sends +GET+ request, returns response object.
|
|
30
30
|
#
|
|
31
31
|
class Net::HTTP::Get < Net::HTTPRequest
|
|
32
|
+
# :stopdoc:
|
|
32
33
|
METHOD = 'GET'
|
|
33
34
|
REQUEST_HAS_BODY = false
|
|
34
35
|
RESPONSE_HAS_BODY = true
|
|
@@ -60,6 +61,7 @@ end
|
|
|
60
61
|
# - Net::HTTP#head: sends +HEAD+ request, returns response object.
|
|
61
62
|
#
|
|
62
63
|
class Net::HTTP::Head < Net::HTTPRequest
|
|
64
|
+
# :stopdoc:
|
|
63
65
|
METHOD = 'HEAD'
|
|
64
66
|
REQUEST_HAS_BODY = false
|
|
65
67
|
RESPONSE_HAS_BODY = false
|
|
@@ -95,6 +97,7 @@ end
|
|
|
95
97
|
# - Net::HTTP#post: sends +POST+ request, returns response object.
|
|
96
98
|
#
|
|
97
99
|
class Net::HTTP::Post < Net::HTTPRequest
|
|
100
|
+
# :stopdoc:
|
|
98
101
|
METHOD = 'POST'
|
|
99
102
|
REQUEST_HAS_BODY = true
|
|
100
103
|
RESPONSE_HAS_BODY = true
|
|
@@ -130,6 +133,7 @@ end
|
|
|
130
133
|
# - Net::HTTP#put: sends +PUT+ request, returns response object.
|
|
131
134
|
#
|
|
132
135
|
class Net::HTTP::Put < Net::HTTPRequest
|
|
136
|
+
# :stopdoc:
|
|
133
137
|
METHOD = 'PUT'
|
|
134
138
|
REQUEST_HAS_BODY = true
|
|
135
139
|
RESPONSE_HAS_BODY = true
|
|
@@ -162,6 +166,7 @@ end
|
|
|
162
166
|
# - Net::HTTP#delete: sends +DELETE+ request, returns response object.
|
|
163
167
|
#
|
|
164
168
|
class Net::HTTP::Delete < Net::HTTPRequest
|
|
169
|
+
# :stopdoc:
|
|
165
170
|
METHOD = 'DELETE'
|
|
166
171
|
REQUEST_HAS_BODY = false
|
|
167
172
|
RESPONSE_HAS_BODY = true
|
|
@@ -193,6 +198,7 @@ end
|
|
|
193
198
|
# - Net::HTTP#options: sends +OPTIONS+ request, returns response object.
|
|
194
199
|
#
|
|
195
200
|
class Net::HTTP::Options < Net::HTTPRequest
|
|
201
|
+
# :stopdoc:
|
|
196
202
|
METHOD = 'OPTIONS'
|
|
197
203
|
REQUEST_HAS_BODY = false
|
|
198
204
|
RESPONSE_HAS_BODY = true
|
|
@@ -224,6 +230,7 @@ end
|
|
|
224
230
|
# - Net::HTTP#trace: sends +TRACE+ request, returns response object.
|
|
225
231
|
#
|
|
226
232
|
class Net::HTTP::Trace < Net::HTTPRequest
|
|
233
|
+
# :stopdoc:
|
|
227
234
|
METHOD = 'TRACE'
|
|
228
235
|
REQUEST_HAS_BODY = false
|
|
229
236
|
RESPONSE_HAS_BODY = true
|
|
@@ -258,6 +265,7 @@ end
|
|
|
258
265
|
# - Net::HTTP#patch: sends +PATCH+ request, returns response object.
|
|
259
266
|
#
|
|
260
267
|
class Net::HTTP::Patch < Net::HTTPRequest
|
|
268
|
+
# :stopdoc:
|
|
261
269
|
METHOD = 'PATCH'
|
|
262
270
|
REQUEST_HAS_BODY = true
|
|
263
271
|
RESPONSE_HAS_BODY = true
|
|
@@ -285,6 +293,7 @@ end
|
|
|
285
293
|
# - Net::HTTP#propfind: sends +PROPFIND+ request, returns response object.
|
|
286
294
|
#
|
|
287
295
|
class Net::HTTP::Propfind < Net::HTTPRequest
|
|
296
|
+
# :stopdoc:
|
|
288
297
|
METHOD = 'PROPFIND'
|
|
289
298
|
REQUEST_HAS_BODY = true
|
|
290
299
|
RESPONSE_HAS_BODY = true
|
|
@@ -308,6 +317,7 @@ end
|
|
|
308
317
|
# - Net::HTTP#proppatch: sends +PROPPATCH+ request, returns response object.
|
|
309
318
|
#
|
|
310
319
|
class Net::HTTP::Proppatch < Net::HTTPRequest
|
|
320
|
+
# :stopdoc:
|
|
311
321
|
METHOD = 'PROPPATCH'
|
|
312
322
|
REQUEST_HAS_BODY = true
|
|
313
323
|
RESPONSE_HAS_BODY = true
|
|
@@ -331,6 +341,7 @@ end
|
|
|
331
341
|
# - Net::HTTP#mkcol: sends +MKCOL+ request, returns response object.
|
|
332
342
|
#
|
|
333
343
|
class Net::HTTP::Mkcol < Net::HTTPRequest
|
|
344
|
+
# :stopdoc:
|
|
334
345
|
METHOD = 'MKCOL'
|
|
335
346
|
REQUEST_HAS_BODY = true
|
|
336
347
|
RESPONSE_HAS_BODY = true
|
|
@@ -354,6 +365,7 @@ end
|
|
|
354
365
|
# - Net::HTTP#copy: sends +COPY+ request, returns response object.
|
|
355
366
|
#
|
|
356
367
|
class Net::HTTP::Copy < Net::HTTPRequest
|
|
368
|
+
# :stopdoc:
|
|
357
369
|
METHOD = 'COPY'
|
|
358
370
|
REQUEST_HAS_BODY = false
|
|
359
371
|
RESPONSE_HAS_BODY = true
|
|
@@ -377,6 +389,7 @@ end
|
|
|
377
389
|
# - Net::HTTP#move: sends +MOVE+ request, returns response object.
|
|
378
390
|
#
|
|
379
391
|
class Net::HTTP::Move < Net::HTTPRequest
|
|
392
|
+
# :stopdoc:
|
|
380
393
|
METHOD = 'MOVE'
|
|
381
394
|
REQUEST_HAS_BODY = false
|
|
382
395
|
RESPONSE_HAS_BODY = true
|
|
@@ -400,6 +413,7 @@ end
|
|
|
400
413
|
# - Net::HTTP#lock: sends +LOCK+ request, returns response object.
|
|
401
414
|
#
|
|
402
415
|
class Net::HTTP::Lock < Net::HTTPRequest
|
|
416
|
+
# :stopdoc:
|
|
403
417
|
METHOD = 'LOCK'
|
|
404
418
|
REQUEST_HAS_BODY = true
|
|
405
419
|
RESPONSE_HAS_BODY = true
|
|
@@ -423,8 +437,8 @@ end
|
|
|
423
437
|
# - Net::HTTP#unlock: sends +UNLOCK+ request, returns response object.
|
|
424
438
|
#
|
|
425
439
|
class Net::HTTP::Unlock < Net::HTTPRequest
|
|
440
|
+
# :stopdoc:
|
|
426
441
|
METHOD = 'UNLOCK'
|
|
427
442
|
REQUEST_HAS_BODY = true
|
|
428
443
|
RESPONSE_HAS_BODY = true
|
|
429
444
|
end
|
|
430
|
-
|
data/lib/net/http/response.rb
CHANGED
|
@@ -153,6 +153,7 @@ class Net::HTTPResponse
|
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
private
|
|
156
|
+
# :stopdoc:
|
|
156
157
|
|
|
157
158
|
def read_status_line(sock)
|
|
158
159
|
str = sock.readline
|
|
@@ -259,7 +260,7 @@ class Net::HTTPResponse
|
|
|
259
260
|
# header.
|
|
260
261
|
attr_accessor :ignore_eof
|
|
261
262
|
|
|
262
|
-
def inspect
|
|
263
|
+
def inspect # :nodoc:
|
|
263
264
|
"#<#{self.class} #{@code} #{@message} readbody=#{@read}>"
|
|
264
265
|
end
|
|
265
266
|
|
data/lib/net/http/responses.rb
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
module Net
|
|
6
6
|
|
|
7
|
+
# Unknown HTTP response
|
|
7
8
|
class HTTPUnknownResponse < HTTPResponse
|
|
9
|
+
# :stopdoc:
|
|
8
10
|
HAS_BODY = true
|
|
9
11
|
EXCEPTION_TYPE = HTTPError #
|
|
10
12
|
end
|
|
@@ -19,6 +21,7 @@ module Net
|
|
|
19
21
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#1xx_informational_response].
|
|
20
22
|
#
|
|
21
23
|
class HTTPInformation < HTTPResponse
|
|
24
|
+
# :stopdoc:
|
|
22
25
|
HAS_BODY = false
|
|
23
26
|
EXCEPTION_TYPE = HTTPError #
|
|
24
27
|
end
|
|
@@ -34,6 +37,7 @@ module Net
|
|
|
34
37
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_success].
|
|
35
38
|
#
|
|
36
39
|
class HTTPSuccess < HTTPResponse
|
|
40
|
+
# :stopdoc:
|
|
37
41
|
HAS_BODY = true
|
|
38
42
|
EXCEPTION_TYPE = HTTPError #
|
|
39
43
|
end
|
|
@@ -49,6 +53,7 @@ module Net
|
|
|
49
53
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_redirection].
|
|
50
54
|
#
|
|
51
55
|
class HTTPRedirection < HTTPResponse
|
|
56
|
+
# :stopdoc:
|
|
52
57
|
HAS_BODY = true
|
|
53
58
|
EXCEPTION_TYPE = HTTPRetriableError #
|
|
54
59
|
end
|
|
@@ -63,6 +68,7 @@ module Net
|
|
|
63
68
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_client_errors].
|
|
64
69
|
#
|
|
65
70
|
class HTTPClientError < HTTPResponse
|
|
71
|
+
# :stopdoc:
|
|
66
72
|
HAS_BODY = true
|
|
67
73
|
EXCEPTION_TYPE = HTTPClientException #
|
|
68
74
|
end
|
|
@@ -77,6 +83,7 @@ module Net
|
|
|
77
83
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_server_errors].
|
|
78
84
|
#
|
|
79
85
|
class HTTPServerError < HTTPResponse
|
|
86
|
+
# :stopdoc:
|
|
80
87
|
HAS_BODY = true
|
|
81
88
|
EXCEPTION_TYPE = HTTPFatalError #
|
|
82
89
|
end
|
|
@@ -94,6 +101,7 @@ module Net
|
|
|
94
101
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#100].
|
|
95
102
|
#
|
|
96
103
|
class HTTPContinue < HTTPInformation
|
|
104
|
+
# :stopdoc:
|
|
97
105
|
HAS_BODY = false
|
|
98
106
|
end
|
|
99
107
|
|
|
@@ -111,6 +119,7 @@ module Net
|
|
|
111
119
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#101].
|
|
112
120
|
#
|
|
113
121
|
class HTTPSwitchProtocol < HTTPInformation
|
|
122
|
+
# :stopdoc:
|
|
114
123
|
HAS_BODY = false
|
|
115
124
|
end
|
|
116
125
|
|
|
@@ -127,6 +136,7 @@ module Net
|
|
|
127
136
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#102].
|
|
128
137
|
#
|
|
129
138
|
class HTTPProcessing < HTTPInformation
|
|
139
|
+
# :stopdoc:
|
|
130
140
|
HAS_BODY = false
|
|
131
141
|
end
|
|
132
142
|
|
|
@@ -145,6 +155,7 @@ module Net
|
|
|
145
155
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#103].
|
|
146
156
|
#
|
|
147
157
|
class HTTPEarlyHints < HTTPInformation
|
|
158
|
+
# :stopdoc:
|
|
148
159
|
HAS_BODY = false
|
|
149
160
|
end
|
|
150
161
|
|
|
@@ -162,6 +173,7 @@ module Net
|
|
|
162
173
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#200].
|
|
163
174
|
#
|
|
164
175
|
class HTTPOK < HTTPSuccess
|
|
176
|
+
# :stopdoc:
|
|
165
177
|
HAS_BODY = true
|
|
166
178
|
end
|
|
167
179
|
|
|
@@ -179,6 +191,7 @@ module Net
|
|
|
179
191
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#201].
|
|
180
192
|
#
|
|
181
193
|
class HTTPCreated < HTTPSuccess
|
|
194
|
+
# :stopdoc:
|
|
182
195
|
HAS_BODY = true
|
|
183
196
|
end
|
|
184
197
|
|
|
@@ -196,6 +209,7 @@ module Net
|
|
|
196
209
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#202].
|
|
197
210
|
#
|
|
198
211
|
class HTTPAccepted < HTTPSuccess
|
|
212
|
+
# :stopdoc:
|
|
199
213
|
HAS_BODY = true
|
|
200
214
|
end
|
|
201
215
|
|
|
@@ -215,6 +229,7 @@ module Net
|
|
|
215
229
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#203].
|
|
216
230
|
#
|
|
217
231
|
class HTTPNonAuthoritativeInformation < HTTPSuccess
|
|
232
|
+
# :stopdoc:
|
|
218
233
|
HAS_BODY = true
|
|
219
234
|
end
|
|
220
235
|
|
|
@@ -232,6 +247,7 @@ module Net
|
|
|
232
247
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#204].
|
|
233
248
|
#
|
|
234
249
|
class HTTPNoContent < HTTPSuccess
|
|
250
|
+
# :stopdoc:
|
|
235
251
|
HAS_BODY = false
|
|
236
252
|
end
|
|
237
253
|
|
|
@@ -250,6 +266,7 @@ module Net
|
|
|
250
266
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#205].
|
|
251
267
|
#
|
|
252
268
|
class HTTPResetContent < HTTPSuccess
|
|
269
|
+
# :stopdoc:
|
|
253
270
|
HAS_BODY = false
|
|
254
271
|
end
|
|
255
272
|
|
|
@@ -268,6 +285,7 @@ module Net
|
|
|
268
285
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#206].
|
|
269
286
|
#
|
|
270
287
|
class HTTPPartialContent < HTTPSuccess
|
|
288
|
+
# :stopdoc:
|
|
271
289
|
HAS_BODY = true
|
|
272
290
|
end
|
|
273
291
|
|
|
@@ -285,6 +303,7 @@ module Net
|
|
|
285
303
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#207].
|
|
286
304
|
#
|
|
287
305
|
class HTTPMultiStatus < HTTPSuccess
|
|
306
|
+
# :stopdoc:
|
|
288
307
|
HAS_BODY = true
|
|
289
308
|
end
|
|
290
309
|
|
|
@@ -304,6 +323,7 @@ module Net
|
|
|
304
323
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#208].
|
|
305
324
|
#
|
|
306
325
|
class HTTPAlreadyReported < HTTPSuccess
|
|
326
|
+
# :stopdoc:
|
|
307
327
|
HAS_BODY = true
|
|
308
328
|
end
|
|
309
329
|
|
|
@@ -321,6 +341,7 @@ module Net
|
|
|
321
341
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#226].
|
|
322
342
|
#
|
|
323
343
|
class HTTPIMUsed < HTTPSuccess
|
|
344
|
+
# :stopdoc:
|
|
324
345
|
HAS_BODY = true
|
|
325
346
|
end
|
|
326
347
|
|
|
@@ -338,6 +359,7 @@ module Net
|
|
|
338
359
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#300].
|
|
339
360
|
#
|
|
340
361
|
class HTTPMultipleChoices < HTTPRedirection
|
|
362
|
+
# :stopdoc:
|
|
341
363
|
HAS_BODY = true
|
|
342
364
|
end
|
|
343
365
|
HTTPMultipleChoice = HTTPMultipleChoices
|
|
@@ -356,6 +378,7 @@ module Net
|
|
|
356
378
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#301].
|
|
357
379
|
#
|
|
358
380
|
class HTTPMovedPermanently < HTTPRedirection
|
|
381
|
+
# :stopdoc:
|
|
359
382
|
HAS_BODY = true
|
|
360
383
|
end
|
|
361
384
|
|
|
@@ -373,6 +396,7 @@ module Net
|
|
|
373
396
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#302].
|
|
374
397
|
#
|
|
375
398
|
class HTTPFound < HTTPRedirection
|
|
399
|
+
# :stopdoc:
|
|
376
400
|
HAS_BODY = true
|
|
377
401
|
end
|
|
378
402
|
HTTPMovedTemporarily = HTTPFound
|
|
@@ -390,6 +414,7 @@ module Net
|
|
|
390
414
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#303].
|
|
391
415
|
#
|
|
392
416
|
class HTTPSeeOther < HTTPRedirection
|
|
417
|
+
# :stopdoc:
|
|
393
418
|
HAS_BODY = true
|
|
394
419
|
end
|
|
395
420
|
|
|
@@ -407,6 +432,7 @@ module Net
|
|
|
407
432
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#304].
|
|
408
433
|
#
|
|
409
434
|
class HTTPNotModified < HTTPRedirection
|
|
435
|
+
# :stopdoc:
|
|
410
436
|
HAS_BODY = false
|
|
411
437
|
end
|
|
412
438
|
|
|
@@ -423,6 +449,7 @@ module Net
|
|
|
423
449
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#305].
|
|
424
450
|
#
|
|
425
451
|
class HTTPUseProxy < HTTPRedirection
|
|
452
|
+
# :stopdoc:
|
|
426
453
|
HAS_BODY = false
|
|
427
454
|
end
|
|
428
455
|
|
|
@@ -440,6 +467,7 @@ module Net
|
|
|
440
467
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#307].
|
|
441
468
|
#
|
|
442
469
|
class HTTPTemporaryRedirect < HTTPRedirection
|
|
470
|
+
# :stopdoc:
|
|
443
471
|
HAS_BODY = true
|
|
444
472
|
end
|
|
445
473
|
|
|
@@ -456,6 +484,7 @@ module Net
|
|
|
456
484
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#308].
|
|
457
485
|
#
|
|
458
486
|
class HTTPPermanentRedirect < HTTPRedirection
|
|
487
|
+
# :stopdoc:
|
|
459
488
|
HAS_BODY = true
|
|
460
489
|
end
|
|
461
490
|
|
|
@@ -472,6 +501,7 @@ module Net
|
|
|
472
501
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#400].
|
|
473
502
|
#
|
|
474
503
|
class HTTPBadRequest < HTTPClientError
|
|
504
|
+
# :stopdoc:
|
|
475
505
|
HAS_BODY = true
|
|
476
506
|
end
|
|
477
507
|
|
|
@@ -488,6 +518,7 @@ module Net
|
|
|
488
518
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#401].
|
|
489
519
|
#
|
|
490
520
|
class HTTPUnauthorized < HTTPClientError
|
|
521
|
+
# :stopdoc:
|
|
491
522
|
HAS_BODY = true
|
|
492
523
|
end
|
|
493
524
|
|
|
@@ -504,6 +535,7 @@ module Net
|
|
|
504
535
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#402].
|
|
505
536
|
#
|
|
506
537
|
class HTTPPaymentRequired < HTTPClientError
|
|
538
|
+
# :stopdoc:
|
|
507
539
|
HAS_BODY = true
|
|
508
540
|
end
|
|
509
541
|
|
|
@@ -521,6 +553,7 @@ module Net
|
|
|
521
553
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#403].
|
|
522
554
|
#
|
|
523
555
|
class HTTPForbidden < HTTPClientError
|
|
556
|
+
# :stopdoc:
|
|
524
557
|
HAS_BODY = true
|
|
525
558
|
end
|
|
526
559
|
|
|
@@ -537,6 +570,7 @@ module Net
|
|
|
537
570
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#404].
|
|
538
571
|
#
|
|
539
572
|
class HTTPNotFound < HTTPClientError
|
|
573
|
+
# :stopdoc:
|
|
540
574
|
HAS_BODY = true
|
|
541
575
|
end
|
|
542
576
|
|
|
@@ -553,6 +587,7 @@ module Net
|
|
|
553
587
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#405].
|
|
554
588
|
#
|
|
555
589
|
class HTTPMethodNotAllowed < HTTPClientError
|
|
590
|
+
# :stopdoc:
|
|
556
591
|
HAS_BODY = true
|
|
557
592
|
end
|
|
558
593
|
|
|
@@ -570,6 +605,7 @@ module Net
|
|
|
570
605
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#406].
|
|
571
606
|
#
|
|
572
607
|
class HTTPNotAcceptable < HTTPClientError
|
|
608
|
+
# :stopdoc:
|
|
573
609
|
HAS_BODY = true
|
|
574
610
|
end
|
|
575
611
|
|
|
@@ -586,6 +622,7 @@ module Net
|
|
|
586
622
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#407].
|
|
587
623
|
#
|
|
588
624
|
class HTTPProxyAuthenticationRequired < HTTPClientError
|
|
625
|
+
# :stopdoc:
|
|
589
626
|
HAS_BODY = true
|
|
590
627
|
end
|
|
591
628
|
|
|
@@ -602,6 +639,7 @@ module Net
|
|
|
602
639
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#408].
|
|
603
640
|
#
|
|
604
641
|
class HTTPRequestTimeout < HTTPClientError
|
|
642
|
+
# :stopdoc:
|
|
605
643
|
HAS_BODY = true
|
|
606
644
|
end
|
|
607
645
|
HTTPRequestTimeOut = HTTPRequestTimeout
|
|
@@ -619,6 +657,7 @@ module Net
|
|
|
619
657
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#409].
|
|
620
658
|
#
|
|
621
659
|
class HTTPConflict < HTTPClientError
|
|
660
|
+
# :stopdoc:
|
|
622
661
|
HAS_BODY = true
|
|
623
662
|
end
|
|
624
663
|
|
|
@@ -636,6 +675,7 @@ module Net
|
|
|
636
675
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#410].
|
|
637
676
|
#
|
|
638
677
|
class HTTPGone < HTTPClientError
|
|
678
|
+
# :stopdoc:
|
|
639
679
|
HAS_BODY = true
|
|
640
680
|
end
|
|
641
681
|
|
|
@@ -653,6 +693,7 @@ module Net
|
|
|
653
693
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#411].
|
|
654
694
|
#
|
|
655
695
|
class HTTPLengthRequired < HTTPClientError
|
|
696
|
+
# :stopdoc:
|
|
656
697
|
HAS_BODY = true
|
|
657
698
|
end
|
|
658
699
|
|
|
@@ -670,6 +711,7 @@ module Net
|
|
|
670
711
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#412].
|
|
671
712
|
#
|
|
672
713
|
class HTTPPreconditionFailed < HTTPClientError
|
|
714
|
+
# :stopdoc:
|
|
673
715
|
HAS_BODY = true
|
|
674
716
|
end
|
|
675
717
|
|
|
@@ -686,6 +728,7 @@ module Net
|
|
|
686
728
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#413].
|
|
687
729
|
#
|
|
688
730
|
class HTTPPayloadTooLarge < HTTPClientError
|
|
731
|
+
# :stopdoc:
|
|
689
732
|
HAS_BODY = true
|
|
690
733
|
end
|
|
691
734
|
HTTPRequestEntityTooLarge = HTTPPayloadTooLarge
|
|
@@ -703,6 +746,7 @@ module Net
|
|
|
703
746
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#414].
|
|
704
747
|
#
|
|
705
748
|
class HTTPURITooLong < HTTPClientError
|
|
749
|
+
# :stopdoc:
|
|
706
750
|
HAS_BODY = true
|
|
707
751
|
end
|
|
708
752
|
HTTPRequestURITooLong = HTTPURITooLong
|
|
@@ -721,6 +765,7 @@ module Net
|
|
|
721
765
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#415].
|
|
722
766
|
#
|
|
723
767
|
class HTTPUnsupportedMediaType < HTTPClientError
|
|
768
|
+
# :stopdoc:
|
|
724
769
|
HAS_BODY = true
|
|
725
770
|
end
|
|
726
771
|
|
|
@@ -737,6 +782,7 @@ module Net
|
|
|
737
782
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#416].
|
|
738
783
|
#
|
|
739
784
|
class HTTPRangeNotSatisfiable < HTTPClientError
|
|
785
|
+
# :stopdoc:
|
|
740
786
|
HAS_BODY = true
|
|
741
787
|
end
|
|
742
788
|
HTTPRequestedRangeNotSatisfiable = HTTPRangeNotSatisfiable
|
|
@@ -754,6 +800,7 @@ module Net
|
|
|
754
800
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#417].
|
|
755
801
|
#
|
|
756
802
|
class HTTPExpectationFailed < HTTPClientError
|
|
803
|
+
# :stopdoc:
|
|
757
804
|
HAS_BODY = true
|
|
758
805
|
end
|
|
759
806
|
|
|
@@ -774,6 +821,7 @@ module Net
|
|
|
774
821
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#421].
|
|
775
822
|
#
|
|
776
823
|
class HTTPMisdirectedRequest < HTTPClientError
|
|
824
|
+
# :stopdoc:
|
|
777
825
|
HAS_BODY = true
|
|
778
826
|
end
|
|
779
827
|
|
|
@@ -790,6 +838,7 @@ module Net
|
|
|
790
838
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#422].
|
|
791
839
|
#
|
|
792
840
|
class HTTPUnprocessableEntity < HTTPClientError
|
|
841
|
+
# :stopdoc:
|
|
793
842
|
HAS_BODY = true
|
|
794
843
|
end
|
|
795
844
|
|
|
@@ -805,6 +854,7 @@ module Net
|
|
|
805
854
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#423].
|
|
806
855
|
#
|
|
807
856
|
class HTTPLocked < HTTPClientError
|
|
857
|
+
# :stopdoc:
|
|
808
858
|
HAS_BODY = true
|
|
809
859
|
end
|
|
810
860
|
|
|
@@ -821,6 +871,7 @@ module Net
|
|
|
821
871
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#424].
|
|
822
872
|
#
|
|
823
873
|
class HTTPFailedDependency < HTTPClientError
|
|
874
|
+
# :stopdoc:
|
|
824
875
|
HAS_BODY = true
|
|
825
876
|
end
|
|
826
877
|
|
|
@@ -840,6 +891,7 @@ module Net
|
|
|
840
891
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#426].
|
|
841
892
|
#
|
|
842
893
|
class HTTPUpgradeRequired < HTTPClientError
|
|
894
|
+
# :stopdoc:
|
|
843
895
|
HAS_BODY = true
|
|
844
896
|
end
|
|
845
897
|
|
|
@@ -856,6 +908,7 @@ module Net
|
|
|
856
908
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#428].
|
|
857
909
|
#
|
|
858
910
|
class HTTPPreconditionRequired < HTTPClientError
|
|
911
|
+
# :stopdoc:
|
|
859
912
|
HAS_BODY = true
|
|
860
913
|
end
|
|
861
914
|
|
|
@@ -872,6 +925,7 @@ module Net
|
|
|
872
925
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#429].
|
|
873
926
|
#
|
|
874
927
|
class HTTPTooManyRequests < HTTPClientError
|
|
928
|
+
# :stopdoc:
|
|
875
929
|
HAS_BODY = true
|
|
876
930
|
end
|
|
877
931
|
|
|
@@ -889,6 +943,7 @@ module Net
|
|
|
889
943
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#431].
|
|
890
944
|
#
|
|
891
945
|
class HTTPRequestHeaderFieldsTooLarge < HTTPClientError
|
|
946
|
+
# :stopdoc:
|
|
892
947
|
HAS_BODY = true
|
|
893
948
|
end
|
|
894
949
|
|
|
@@ -906,6 +961,7 @@ module Net
|
|
|
906
961
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#451].
|
|
907
962
|
#
|
|
908
963
|
class HTTPUnavailableForLegalReasons < HTTPClientError
|
|
964
|
+
# :stopdoc:
|
|
909
965
|
HAS_BODY = true
|
|
910
966
|
end
|
|
911
967
|
# 444 No Response - Nginx
|
|
@@ -926,6 +982,7 @@ module Net
|
|
|
926
982
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#500].
|
|
927
983
|
#
|
|
928
984
|
class HTTPInternalServerError < HTTPServerError
|
|
985
|
+
# :stopdoc:
|
|
929
986
|
HAS_BODY = true
|
|
930
987
|
end
|
|
931
988
|
|
|
@@ -943,6 +1000,7 @@ module Net
|
|
|
943
1000
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#501].
|
|
944
1001
|
#
|
|
945
1002
|
class HTTPNotImplemented < HTTPServerError
|
|
1003
|
+
# :stopdoc:
|
|
946
1004
|
HAS_BODY = true
|
|
947
1005
|
end
|
|
948
1006
|
|
|
@@ -960,6 +1018,7 @@ module Net
|
|
|
960
1018
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#502].
|
|
961
1019
|
#
|
|
962
1020
|
class HTTPBadGateway < HTTPServerError
|
|
1021
|
+
# :stopdoc:
|
|
963
1022
|
HAS_BODY = true
|
|
964
1023
|
end
|
|
965
1024
|
|
|
@@ -977,6 +1036,7 @@ module Net
|
|
|
977
1036
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#503].
|
|
978
1037
|
#
|
|
979
1038
|
class HTTPServiceUnavailable < HTTPServerError
|
|
1039
|
+
# :stopdoc:
|
|
980
1040
|
HAS_BODY = true
|
|
981
1041
|
end
|
|
982
1042
|
|
|
@@ -994,6 +1054,7 @@ module Net
|
|
|
994
1054
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#504].
|
|
995
1055
|
#
|
|
996
1056
|
class HTTPGatewayTimeout < HTTPServerError
|
|
1057
|
+
# :stopdoc:
|
|
997
1058
|
HAS_BODY = true
|
|
998
1059
|
end
|
|
999
1060
|
HTTPGatewayTimeOut = HTTPGatewayTimeout
|
|
@@ -1011,6 +1072,7 @@ module Net
|
|
|
1011
1072
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#505].
|
|
1012
1073
|
#
|
|
1013
1074
|
class HTTPVersionNotSupported < HTTPServerError
|
|
1075
|
+
# :stopdoc:
|
|
1014
1076
|
HAS_BODY = true
|
|
1015
1077
|
end
|
|
1016
1078
|
|
|
@@ -1027,6 +1089,7 @@ module Net
|
|
|
1027
1089
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#506].
|
|
1028
1090
|
#
|
|
1029
1091
|
class HTTPVariantAlsoNegotiates < HTTPServerError
|
|
1092
|
+
# :stopdoc:
|
|
1030
1093
|
HAS_BODY = true
|
|
1031
1094
|
end
|
|
1032
1095
|
|
|
@@ -1043,6 +1106,7 @@ module Net
|
|
|
1043
1106
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#507].
|
|
1044
1107
|
#
|
|
1045
1108
|
class HTTPInsufficientStorage < HTTPServerError
|
|
1109
|
+
# :stopdoc:
|
|
1046
1110
|
HAS_BODY = true
|
|
1047
1111
|
end
|
|
1048
1112
|
|
|
@@ -1059,6 +1123,7 @@ module Net
|
|
|
1059
1123
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#508].
|
|
1060
1124
|
#
|
|
1061
1125
|
class HTTPLoopDetected < HTTPServerError
|
|
1126
|
+
# :stopdoc:
|
|
1062
1127
|
HAS_BODY = true
|
|
1063
1128
|
end
|
|
1064
1129
|
# 509 Bandwidth Limit Exceeded - Apache bw/limited extension
|
|
@@ -1076,6 +1141,7 @@ module Net
|
|
|
1076
1141
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#510].
|
|
1077
1142
|
#
|
|
1078
1143
|
class HTTPNotExtended < HTTPServerError
|
|
1144
|
+
# :stopdoc:
|
|
1079
1145
|
HAS_BODY = true
|
|
1080
1146
|
end
|
|
1081
1147
|
|
|
@@ -1092,12 +1158,14 @@ module Net
|
|
|
1092
1158
|
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#511].
|
|
1093
1159
|
#
|
|
1094
1160
|
class HTTPNetworkAuthenticationRequired < HTTPServerError
|
|
1161
|
+
# :stopdoc:
|
|
1095
1162
|
HAS_BODY = true
|
|
1096
1163
|
end
|
|
1097
1164
|
|
|
1098
1165
|
end
|
|
1099
1166
|
|
|
1100
1167
|
class Net::HTTPResponse
|
|
1168
|
+
# :stopdoc:
|
|
1101
1169
|
CODE_CLASS_TO_OBJ = {
|
|
1102
1170
|
'1' => Net::HTTPInformation,
|
|
1103
1171
|
'2' => Net::HTTPSuccess,
|
data/lib/net/http.rb
CHANGED
|
@@ -724,7 +724,7 @@ module Net #:nodoc:
|
|
|
724
724
|
class HTTP < Protocol
|
|
725
725
|
|
|
726
726
|
# :stopdoc:
|
|
727
|
-
VERSION = "0.
|
|
727
|
+
VERSION = "0.8.0"
|
|
728
728
|
HTTPVersion = '1.1'
|
|
729
729
|
begin
|
|
730
730
|
require 'zlib'
|
|
@@ -1179,6 +1179,7 @@ module Net #:nodoc:
|
|
|
1179
1179
|
@debug_output = options[:debug_output]
|
|
1180
1180
|
@response_body_encoding = options[:response_body_encoding]
|
|
1181
1181
|
@ignore_eof = options[:ignore_eof]
|
|
1182
|
+
@tcpsocket_supports_open_timeout = nil
|
|
1182
1183
|
|
|
1183
1184
|
@proxy_from_env = false
|
|
1184
1185
|
@proxy_uri = nil
|
|
@@ -1321,6 +1322,9 @@ module Net #:nodoc:
|
|
|
1321
1322
|
# Sets the proxy password;
|
|
1322
1323
|
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
|
1323
1324
|
attr_writer :proxy_pass
|
|
1325
|
+
|
|
1326
|
+
# Sets wheter the proxy uses SSL;
|
|
1327
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
|
1324
1328
|
attr_writer :proxy_use_ssl
|
|
1325
1329
|
|
|
1326
1330
|
# Returns the IP address for the connection.
|
|
@@ -1632,6 +1636,21 @@ module Net #:nodoc:
|
|
|
1632
1636
|
self
|
|
1633
1637
|
end
|
|
1634
1638
|
|
|
1639
|
+
# Finishes the \HTTP session:
|
|
1640
|
+
#
|
|
1641
|
+
# http = Net::HTTP.new(hostname)
|
|
1642
|
+
# http.start
|
|
1643
|
+
# http.started? # => true
|
|
1644
|
+
# http.finish # => nil
|
|
1645
|
+
# http.started? # => false
|
|
1646
|
+
#
|
|
1647
|
+
# Raises IOError if not in a session.
|
|
1648
|
+
def finish
|
|
1649
|
+
raise IOError, 'HTTP session not yet started' unless started?
|
|
1650
|
+
do_finish
|
|
1651
|
+
end
|
|
1652
|
+
|
|
1653
|
+
# :stopdoc:
|
|
1635
1654
|
def do_start
|
|
1636
1655
|
connect
|
|
1637
1656
|
@started = true
|
|
@@ -1654,14 +1673,36 @@ module Net #:nodoc:
|
|
|
1654
1673
|
end
|
|
1655
1674
|
|
|
1656
1675
|
debug "opening connection to #{conn_addr}:#{conn_port}..."
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1676
|
+
begin
|
|
1677
|
+
s =
|
|
1678
|
+
case @tcpsocket_supports_open_timeout
|
|
1679
|
+
when nil, true
|
|
1680
|
+
begin
|
|
1681
|
+
# Use built-in timeout in TCPSocket.open if available
|
|
1682
|
+
sock = TCPSocket.open(conn_addr, conn_port, @local_host, @local_port, open_timeout: @open_timeout)
|
|
1683
|
+
@tcpsocket_supports_open_timeout = true
|
|
1684
|
+
sock
|
|
1685
|
+
rescue ArgumentError => e
|
|
1686
|
+
raise if !(e.message.include?('unknown keyword: :open_timeout') || e.message.include?('wrong number of arguments (given 5, expected 2..4)'))
|
|
1687
|
+
@tcpsocket_supports_open_timeout = false
|
|
1688
|
+
|
|
1689
|
+
# Fallback to Timeout.timeout if TCPSocket.open does not support open_timeout
|
|
1690
|
+
Timeout.timeout(@open_timeout, Net::OpenTimeout) {
|
|
1691
|
+
TCPSocket.open(conn_addr, conn_port, @local_host, @local_port)
|
|
1692
|
+
}
|
|
1693
|
+
end
|
|
1694
|
+
when false
|
|
1695
|
+
# The current Ruby is known to not support TCPSocket(open_timeout:).
|
|
1696
|
+
# Directly fall back to Timeout.timeout to avoid performance penalty incured by rescue.
|
|
1697
|
+
Timeout.timeout(@open_timeout, Net::OpenTimeout) {
|
|
1698
|
+
TCPSocket.open(conn_addr, conn_port, @local_host, @local_port)
|
|
1699
|
+
}
|
|
1700
|
+
end
|
|
1701
|
+
rescue => e
|
|
1702
|
+
e = Net::OpenTimeout.new(e) if e.is_a?(Errno::ETIMEDOUT) # for compatibility with previous versions
|
|
1703
|
+
raise e, "Failed to open TCP connection to " +
|
|
1704
|
+
"#{conn_addr}:#{conn_port} (#{e.message})"
|
|
1705
|
+
end
|
|
1665
1706
|
s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
|
1666
1707
|
debug "opened"
|
|
1667
1708
|
if use_ssl?
|
|
@@ -1758,20 +1799,6 @@ module Net #:nodoc:
|
|
|
1758
1799
|
end
|
|
1759
1800
|
private :on_connect
|
|
1760
1801
|
|
|
1761
|
-
# Finishes the \HTTP session:
|
|
1762
|
-
#
|
|
1763
|
-
# http = Net::HTTP.new(hostname)
|
|
1764
|
-
# http.start
|
|
1765
|
-
# http.started? # => true
|
|
1766
|
-
# http.finish # => nil
|
|
1767
|
-
# http.started? # => false
|
|
1768
|
-
#
|
|
1769
|
-
# Raises IOError if not in a session.
|
|
1770
|
-
def finish
|
|
1771
|
-
raise IOError, 'HTTP session not yet started' unless started?
|
|
1772
|
-
do_finish
|
|
1773
|
-
end
|
|
1774
|
-
|
|
1775
1802
|
def do_finish
|
|
1776
1803
|
@started = false
|
|
1777
1804
|
@socket.close if @socket
|
|
@@ -1821,6 +1848,8 @@ module Net #:nodoc:
|
|
|
1821
1848
|
}
|
|
1822
1849
|
end
|
|
1823
1850
|
|
|
1851
|
+
# :startdoc:
|
|
1852
|
+
|
|
1824
1853
|
class << HTTP
|
|
1825
1854
|
# Returns true if self is a class which was created by HTTP::Proxy.
|
|
1826
1855
|
def proxy_class?
|
|
@@ -1915,6 +1944,7 @@ module Net #:nodoc:
|
|
|
1915
1944
|
alias proxyport proxy_port #:nodoc: obsolete
|
|
1916
1945
|
|
|
1917
1946
|
private
|
|
1947
|
+
# :stopdoc:
|
|
1918
1948
|
|
|
1919
1949
|
def unescape(value)
|
|
1920
1950
|
require 'cgi/escape'
|
|
@@ -1943,6 +1973,7 @@ module Net #:nodoc:
|
|
|
1943
1973
|
path
|
|
1944
1974
|
end
|
|
1945
1975
|
end
|
|
1976
|
+
# :startdoc:
|
|
1946
1977
|
|
|
1947
1978
|
#
|
|
1948
1979
|
# HTTP operations
|
|
@@ -2397,6 +2428,8 @@ module Net #:nodoc:
|
|
|
2397
2428
|
res
|
|
2398
2429
|
end
|
|
2399
2430
|
|
|
2431
|
+
# :stopdoc:
|
|
2432
|
+
|
|
2400
2433
|
IDEMPOTENT_METHODS_ = %w/GET HEAD PUT DELETE OPTIONS TRACE/ # :nodoc:
|
|
2401
2434
|
|
|
2402
2435
|
def transport_request(req)
|
|
@@ -2554,7 +2587,7 @@ module Net #:nodoc:
|
|
|
2554
2587
|
alias_method :D, :debug
|
|
2555
2588
|
end
|
|
2556
2589
|
|
|
2557
|
-
# for backward compatibility until Ruby
|
|
2590
|
+
# for backward compatibility until Ruby 4.0
|
|
2558
2591
|
# https://bugs.ruby-lang.org/issues/20900
|
|
2559
2592
|
# https://github.com/bblimke/webmock/pull/1081
|
|
2560
2593
|
HTTPSession = HTTP
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: net-http
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- NARUSE, Yui
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version:
|
|
18
|
+
version: 0.11.1
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version:
|
|
25
|
+
version: 0.11.1
|
|
26
26
|
description: HTTP client api for Ruby.
|
|
27
27
|
email:
|
|
28
28
|
- naruse@airemix.jp
|
|
@@ -30,13 +30,10 @@ executables: []
|
|
|
30
30
|
extensions: []
|
|
31
31
|
extra_rdoc_files: []
|
|
32
32
|
files:
|
|
33
|
+
- ".document"
|
|
33
34
|
- BSDL
|
|
34
35
|
- COPYING
|
|
35
|
-
- Gemfile
|
|
36
36
|
- README.md
|
|
37
|
-
- Rakefile
|
|
38
|
-
- bin/console
|
|
39
|
-
- bin/setup
|
|
40
37
|
- doc/net-http/examples.rdoc
|
|
41
38
|
- doc/net-http/included_getters.rdoc
|
|
42
39
|
- lib/net/http.rb
|
|
@@ -50,7 +47,6 @@ files:
|
|
|
50
47
|
- lib/net/http/responses.rb
|
|
51
48
|
- lib/net/http/status.rb
|
|
52
49
|
- lib/net/https.rb
|
|
53
|
-
- net-http.gemspec
|
|
54
50
|
homepage: https://github.com/ruby/net-http
|
|
55
51
|
licenses:
|
|
56
52
|
- Ruby
|
|
@@ -66,7 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
66
62
|
requirements:
|
|
67
63
|
- - ">="
|
|
68
64
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: 2.
|
|
65
|
+
version: 2.7.0
|
|
70
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
67
|
requirements:
|
|
72
68
|
- - ">="
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/bin/console
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require "bundler/setup"
|
|
4
|
-
require "net/http"
|
|
5
|
-
|
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
-
|
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
-
# require "pry"
|
|
11
|
-
# Pry.start
|
|
12
|
-
|
|
13
|
-
require "irb"
|
|
14
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
data/net-http.gemspec
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
name = File.basename(__FILE__, ".gemspec")
|
|
4
|
-
version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
|
|
5
|
-
file = File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")
|
|
6
|
-
begin
|
|
7
|
-
break File.foreach(file, mode: "rb") do |line|
|
|
8
|
-
/^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
|
|
9
|
-
end
|
|
10
|
-
rescue SystemCallError
|
|
11
|
-
next
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
Gem::Specification.new do |spec|
|
|
16
|
-
spec.name = name
|
|
17
|
-
spec.version = version
|
|
18
|
-
spec.authors = ["NARUSE, Yui"]
|
|
19
|
-
spec.email = ["naruse@airemix.jp"]
|
|
20
|
-
|
|
21
|
-
spec.summary = %q{HTTP client api for Ruby.}
|
|
22
|
-
spec.description = %q{HTTP client api for Ruby.}
|
|
23
|
-
spec.homepage = "https://github.com/ruby/net-http"
|
|
24
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
|
25
|
-
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
|
26
|
-
|
|
27
|
-
spec.metadata["changelog_uri"] = spec.homepage + "/releases"
|
|
28
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
|
29
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
|
30
|
-
|
|
31
|
-
# Specify which files should be added to the gem when it is released.
|
|
32
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
33
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
34
|
-
`git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{\A(?:(?:test|spec|features)/|\.git)}) }
|
|
35
|
-
end
|
|
36
|
-
spec.bindir = "exe"
|
|
37
|
-
spec.require_paths = ["lib"]
|
|
38
|
-
|
|
39
|
-
spec.add_dependency "uri"
|
|
40
|
-
end
|