net-http 0.2.2 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/doc/net-http/examples.rdoc +30 -0
- data/lib/net/http/exceptions.rb +27 -26
- data/lib/net/http/generic_request.rb +2 -1
- data/lib/net/http/header.rb +384 -75
- data/lib/net/http/request.rb +27 -5
- data/lib/net/http/requests.rb +296 -24
- data/lib/net/http/response.rb +127 -11
- data/lib/net/http/responses.rb +228 -223
- data/lib/net/http.rb +321 -311
- metadata +3 -2
data/lib/net/http/responses.rb
CHANGED
@@ -1,231 +1,238 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
#--
|
3
3
|
# https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
|
4
|
-
class Net::HTTPUnknownResponse < Net::HTTPResponse
|
5
|
-
HAS_BODY = true
|
6
|
-
EXCEPTION_TYPE = Net::HTTPError
|
7
|
-
end
|
8
|
-
class Net::HTTPInformation < Net::HTTPResponse # 1xx
|
9
|
-
HAS_BODY = false
|
10
|
-
EXCEPTION_TYPE = Net::HTTPError
|
11
|
-
end
|
12
|
-
class Net::HTTPSuccess < Net::HTTPResponse # 2xx
|
13
|
-
HAS_BODY = true
|
14
|
-
EXCEPTION_TYPE = Net::HTTPError
|
15
|
-
end
|
16
|
-
class Net::HTTPRedirection < Net::HTTPResponse # 3xx
|
17
|
-
HAS_BODY = true
|
18
|
-
EXCEPTION_TYPE = Net::HTTPRetriableError
|
19
|
-
end
|
20
|
-
class Net::HTTPClientError < Net::HTTPResponse # 4xx
|
21
|
-
HAS_BODY = true
|
22
|
-
EXCEPTION_TYPE = Net::HTTPClientException # for backward compatibility
|
23
|
-
end
|
24
|
-
class Net::HTTPServerError < Net::HTTPResponse # 5xx
|
25
|
-
HAS_BODY = true
|
26
|
-
EXCEPTION_TYPE = Net::HTTPFatalError # for backward compatibility
|
27
|
-
end
|
28
4
|
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
class Net::HTTPSwitchProtocol < Net::HTTPInformation # 101
|
33
|
-
HAS_BODY = false
|
34
|
-
end
|
35
|
-
class Net::HTTPProcessing < Net::HTTPInformation # 102
|
36
|
-
HAS_BODY = false
|
37
|
-
end
|
38
|
-
class Net::HTTPEarlyHints < Net::HTTPInformation # 103 - RFC 8297
|
39
|
-
HAS_BODY = false
|
40
|
-
end
|
5
|
+
module Net
|
6
|
+
# :stopdoc:
|
41
7
|
|
42
|
-
class
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
class
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
class Net::HTTPAlreadyReported < Net::HTTPSuccess # 208 - RFC 5842
|
67
|
-
HAS_BODY = true
|
68
|
-
end
|
69
|
-
class Net::HTTPIMUsed < Net::HTTPSuccess # 226 - RFC 3229
|
70
|
-
HAS_BODY = true
|
71
|
-
end
|
8
|
+
class HTTPUnknownResponse < HTTPResponse
|
9
|
+
HAS_BODY = true
|
10
|
+
EXCEPTION_TYPE = HTTPError #
|
11
|
+
end
|
12
|
+
class HTTPInformation < HTTPResponse # 1xx
|
13
|
+
HAS_BODY = false
|
14
|
+
EXCEPTION_TYPE = HTTPError #
|
15
|
+
end
|
16
|
+
class HTTPSuccess < HTTPResponse # 2xx
|
17
|
+
HAS_BODY = true
|
18
|
+
EXCEPTION_TYPE = HTTPError #
|
19
|
+
end
|
20
|
+
class HTTPRedirection < HTTPResponse # 3xx
|
21
|
+
HAS_BODY = true
|
22
|
+
EXCEPTION_TYPE = HTTPRetriableError #
|
23
|
+
end
|
24
|
+
class HTTPClientError < HTTPResponse # 4xx
|
25
|
+
HAS_BODY = true
|
26
|
+
EXCEPTION_TYPE = HTTPClientException #
|
27
|
+
end
|
28
|
+
class HTTPServerError < HTTPResponse # 5xx
|
29
|
+
HAS_BODY = true
|
30
|
+
EXCEPTION_TYPE = HTTPFatalError #
|
31
|
+
end
|
72
32
|
|
73
|
-
class
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
HAS_BODY = true
|
86
|
-
end
|
87
|
-
class Net::HTTPNotModified < Net::HTTPRedirection # 304
|
88
|
-
HAS_BODY = false
|
89
|
-
end
|
90
|
-
class Net::HTTPUseProxy < Net::HTTPRedirection # 305
|
91
|
-
HAS_BODY = false
|
92
|
-
end
|
93
|
-
# 306 Switch Proxy - no longer unused
|
94
|
-
class Net::HTTPTemporaryRedirect < Net::HTTPRedirection # 307
|
95
|
-
HAS_BODY = true
|
96
|
-
end
|
97
|
-
class Net::HTTPPermanentRedirect < Net::HTTPRedirection # 308
|
98
|
-
HAS_BODY = true
|
99
|
-
end
|
33
|
+
class HTTPContinue < HTTPInformation # 100
|
34
|
+
HAS_BODY = false
|
35
|
+
end
|
36
|
+
class HTTPSwitchProtocol < HTTPInformation # 101
|
37
|
+
HAS_BODY = false
|
38
|
+
end
|
39
|
+
class HTTPProcessing < HTTPInformation # 102
|
40
|
+
HAS_BODY = false
|
41
|
+
end
|
42
|
+
class HTTPEarlyHints < HTTPInformation # 103 - RFC 8297
|
43
|
+
HAS_BODY = false
|
44
|
+
end
|
100
45
|
|
101
|
-
class
|
102
|
-
|
103
|
-
end
|
104
|
-
class
|
105
|
-
|
106
|
-
end
|
107
|
-
class
|
108
|
-
|
109
|
-
end
|
110
|
-
class
|
111
|
-
|
112
|
-
end
|
113
|
-
class
|
114
|
-
|
115
|
-
end
|
116
|
-
class
|
117
|
-
|
118
|
-
end
|
119
|
-
class
|
120
|
-
|
121
|
-
end
|
122
|
-
class
|
123
|
-
|
124
|
-
end
|
125
|
-
class
|
126
|
-
|
127
|
-
end
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
end
|
132
|
-
class Net::HTTPGone < Net::HTTPClientError # 410
|
133
|
-
HAS_BODY = true
|
134
|
-
end
|
135
|
-
class Net::HTTPLengthRequired < Net::HTTPClientError # 411
|
136
|
-
HAS_BODY = true
|
137
|
-
end
|
138
|
-
class Net::HTTPPreconditionFailed < Net::HTTPClientError # 412
|
139
|
-
HAS_BODY = true
|
140
|
-
end
|
141
|
-
class Net::HTTPPayloadTooLarge < Net::HTTPClientError # 413
|
142
|
-
HAS_BODY = true
|
143
|
-
end
|
144
|
-
Net::HTTPRequestEntityTooLarge = Net::HTTPPayloadTooLarge
|
145
|
-
class Net::HTTPURITooLong < Net::HTTPClientError # 414
|
146
|
-
HAS_BODY = true
|
147
|
-
end
|
148
|
-
Net::HTTPRequestURITooLong = Net::HTTPURITooLong
|
149
|
-
Net::HTTPRequestURITooLarge = Net::HTTPRequestURITooLong
|
150
|
-
class Net::HTTPUnsupportedMediaType < Net::HTTPClientError # 415
|
151
|
-
HAS_BODY = true
|
152
|
-
end
|
153
|
-
class Net::HTTPRangeNotSatisfiable < Net::HTTPClientError # 416
|
154
|
-
HAS_BODY = true
|
155
|
-
end
|
156
|
-
Net::HTTPRequestedRangeNotSatisfiable = Net::HTTPRangeNotSatisfiable
|
157
|
-
class Net::HTTPExpectationFailed < Net::HTTPClientError # 417
|
158
|
-
HAS_BODY = true
|
159
|
-
end
|
160
|
-
# 418 I'm a teapot - RFC 2324; a joke RFC
|
161
|
-
# 420 Enhance Your Calm - Twitter
|
162
|
-
class Net::HTTPMisdirectedRequest < Net::HTTPClientError # 421 - RFC 7540
|
163
|
-
HAS_BODY = true
|
164
|
-
end
|
165
|
-
class Net::HTTPUnprocessableEntity < Net::HTTPClientError # 422 - RFC 4918
|
166
|
-
HAS_BODY = true
|
167
|
-
end
|
168
|
-
class Net::HTTPLocked < Net::HTTPClientError # 423 - RFC 4918
|
169
|
-
HAS_BODY = true
|
170
|
-
end
|
171
|
-
class Net::HTTPFailedDependency < Net::HTTPClientError # 424 - RFC 4918
|
172
|
-
HAS_BODY = true
|
173
|
-
end
|
174
|
-
# 425 Unordered Collection - existed only in draft
|
175
|
-
class Net::HTTPUpgradeRequired < Net::HTTPClientError # 426 - RFC 2817
|
176
|
-
HAS_BODY = true
|
177
|
-
end
|
178
|
-
class Net::HTTPPreconditionRequired < Net::HTTPClientError # 428 - RFC 6585
|
179
|
-
HAS_BODY = true
|
180
|
-
end
|
181
|
-
class Net::HTTPTooManyRequests < Net::HTTPClientError # 429 - RFC 6585
|
182
|
-
HAS_BODY = true
|
183
|
-
end
|
184
|
-
class Net::HTTPRequestHeaderFieldsTooLarge < Net::HTTPClientError # 431 - RFC 6585
|
185
|
-
HAS_BODY = true
|
186
|
-
end
|
187
|
-
class Net::HTTPUnavailableForLegalReasons < Net::HTTPClientError # 451 - RFC 7725
|
188
|
-
HAS_BODY = true
|
189
|
-
end
|
190
|
-
# 444 No Response - Nginx
|
191
|
-
# 449 Retry With - Microsoft
|
192
|
-
# 450 Blocked by Windows Parental Controls - Microsoft
|
193
|
-
# 499 Client Closed Request - Nginx
|
46
|
+
class HTTPOK < HTTPSuccess # 200
|
47
|
+
HAS_BODY = true
|
48
|
+
end
|
49
|
+
class HTTPCreated < HTTPSuccess # 201
|
50
|
+
HAS_BODY = true
|
51
|
+
end
|
52
|
+
class HTTPAccepted < HTTPSuccess # 202
|
53
|
+
HAS_BODY = true
|
54
|
+
end
|
55
|
+
class HTTPNonAuthoritativeInformation < HTTPSuccess # 203
|
56
|
+
HAS_BODY = true
|
57
|
+
end
|
58
|
+
class HTTPNoContent < HTTPSuccess # 204
|
59
|
+
HAS_BODY = false
|
60
|
+
end
|
61
|
+
class HTTPResetContent < HTTPSuccess # 205
|
62
|
+
HAS_BODY = false
|
63
|
+
end
|
64
|
+
class HTTPPartialContent < HTTPSuccess # 206
|
65
|
+
HAS_BODY = true
|
66
|
+
end
|
67
|
+
class HTTPMultiStatus < HTTPSuccess # 207 - RFC 4918
|
68
|
+
HAS_BODY = true
|
69
|
+
end
|
70
|
+
class HTTPAlreadyReported < HTTPSuccess # 208 - RFC 5842
|
71
|
+
HAS_BODY = true
|
72
|
+
end
|
73
|
+
class HTTPIMUsed < HTTPSuccess # 226 - RFC 3229
|
74
|
+
HAS_BODY = true
|
75
|
+
end
|
194
76
|
|
195
|
-
class
|
196
|
-
|
197
|
-
end
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
77
|
+
class HTTPMultipleChoices < HTTPRedirection # 300
|
78
|
+
HAS_BODY = true
|
79
|
+
end
|
80
|
+
HTTPMultipleChoice = HTTPMultipleChoices
|
81
|
+
class HTTPMovedPermanently < HTTPRedirection # 301
|
82
|
+
HAS_BODY = true
|
83
|
+
end
|
84
|
+
class HTTPFound < HTTPRedirection # 302
|
85
|
+
HAS_BODY = true
|
86
|
+
end
|
87
|
+
HTTPMovedTemporarily = HTTPFound
|
88
|
+
class HTTPSeeOther < HTTPRedirection # 303
|
89
|
+
HAS_BODY = true
|
90
|
+
end
|
91
|
+
class HTTPNotModified < HTTPRedirection # 304
|
92
|
+
HAS_BODY = false
|
93
|
+
end
|
94
|
+
class HTTPUseProxy < HTTPRedirection # 305
|
95
|
+
HAS_BODY = false
|
96
|
+
end
|
97
|
+
# 306 Switch Proxy - no longer unused
|
98
|
+
class HTTPTemporaryRedirect < HTTPRedirection # 307
|
99
|
+
HAS_BODY = true
|
100
|
+
end
|
101
|
+
class HTTPPermanentRedirect < HTTPRedirection # 308
|
102
|
+
HAS_BODY = true
|
103
|
+
end
|
104
|
+
|
105
|
+
class HTTPBadRequest < HTTPClientError # 400
|
106
|
+
HAS_BODY = true
|
107
|
+
end
|
108
|
+
class HTTPUnauthorized < HTTPClientError # 401
|
109
|
+
HAS_BODY = true
|
110
|
+
end
|
111
|
+
class HTTPPaymentRequired < HTTPClientError # 402
|
112
|
+
HAS_BODY = true
|
113
|
+
end
|
114
|
+
class HTTPForbidden < HTTPClientError # 403
|
115
|
+
HAS_BODY = true
|
116
|
+
end
|
117
|
+
class HTTPNotFound < HTTPClientError # 404
|
118
|
+
HAS_BODY = true
|
119
|
+
end
|
120
|
+
class HTTPMethodNotAllowed < HTTPClientError # 405
|
121
|
+
HAS_BODY = true
|
122
|
+
end
|
123
|
+
class HTTPNotAcceptable < HTTPClientError # 406
|
124
|
+
HAS_BODY = true
|
125
|
+
end
|
126
|
+
class HTTPProxyAuthenticationRequired < HTTPClientError # 407
|
127
|
+
HAS_BODY = true
|
128
|
+
end
|
129
|
+
class HTTPRequestTimeout < HTTPClientError # 408
|
130
|
+
HAS_BODY = true
|
131
|
+
end
|
132
|
+
HTTPRequestTimeOut = HTTPRequestTimeout
|
133
|
+
class HTTPConflict < HTTPClientError # 409
|
134
|
+
HAS_BODY = true
|
135
|
+
end
|
136
|
+
class HTTPGone < HTTPClientError # 410
|
137
|
+
HAS_BODY = true
|
138
|
+
end
|
139
|
+
class HTTPLengthRequired < HTTPClientError # 411
|
140
|
+
HAS_BODY = true
|
141
|
+
end
|
142
|
+
class HTTPPreconditionFailed < HTTPClientError # 412
|
143
|
+
HAS_BODY = true
|
144
|
+
end
|
145
|
+
class HTTPPayloadTooLarge < HTTPClientError # 413
|
146
|
+
HAS_BODY = true
|
147
|
+
end
|
148
|
+
HTTPRequestEntityTooLarge = HTTPPayloadTooLarge
|
149
|
+
class HTTPURITooLong < HTTPClientError # 414
|
150
|
+
HAS_BODY = true
|
151
|
+
end
|
152
|
+
HTTPRequestURITooLong = HTTPURITooLong
|
153
|
+
HTTPRequestURITooLarge = HTTPRequestURITooLong
|
154
|
+
class HTTPUnsupportedMediaType < HTTPClientError # 415
|
155
|
+
HAS_BODY = true
|
156
|
+
end
|
157
|
+
class HTTPRangeNotSatisfiable < HTTPClientError # 416
|
158
|
+
HAS_BODY = true
|
159
|
+
end
|
160
|
+
HTTPRequestedRangeNotSatisfiable = HTTPRangeNotSatisfiable
|
161
|
+
class HTTPExpectationFailed < HTTPClientError # 417
|
162
|
+
HAS_BODY = true
|
163
|
+
end
|
164
|
+
# 418 I'm a teapot - RFC 2324; a joke RFC
|
165
|
+
# 420 Enhance Your Calm - Twitter
|
166
|
+
class HTTPMisdirectedRequest < HTTPClientError # 421 - RFC 7540
|
167
|
+
HAS_BODY = true
|
168
|
+
end
|
169
|
+
class HTTPUnprocessableEntity < HTTPClientError # 422 - RFC 4918
|
170
|
+
HAS_BODY = true
|
171
|
+
end
|
172
|
+
class HTTPLocked < HTTPClientError # 423 - RFC 4918
|
173
|
+
HAS_BODY = true
|
174
|
+
end
|
175
|
+
class HTTPFailedDependency < HTTPClientError # 424 - RFC 4918
|
176
|
+
HAS_BODY = true
|
177
|
+
end
|
178
|
+
# 425 Unordered Collection - existed only in draft
|
179
|
+
class HTTPUpgradeRequired < HTTPClientError # 426 - RFC 2817
|
180
|
+
HAS_BODY = true
|
181
|
+
end
|
182
|
+
class HTTPPreconditionRequired < HTTPClientError # 428 - RFC 6585
|
183
|
+
HAS_BODY = true
|
184
|
+
end
|
185
|
+
class HTTPTooManyRequests < HTTPClientError # 429 - RFC 6585
|
186
|
+
HAS_BODY = true
|
187
|
+
end
|
188
|
+
class HTTPRequestHeaderFieldsTooLarge < HTTPClientError # 431 - RFC 6585
|
189
|
+
HAS_BODY = true
|
190
|
+
end
|
191
|
+
class HTTPUnavailableForLegalReasons < HTTPClientError # 451 - RFC 7725
|
192
|
+
HAS_BODY = true
|
193
|
+
end
|
194
|
+
# 444 No Response - Nginx
|
195
|
+
# 449 Retry With - Microsoft
|
196
|
+
# 450 Blocked by Windows Parental Controls - Microsoft
|
197
|
+
# 499 Client Closed Request - Nginx
|
198
|
+
|
199
|
+
class HTTPInternalServerError < HTTPServerError # 500
|
200
|
+
HAS_BODY = true
|
201
|
+
end
|
202
|
+
class HTTPNotImplemented < HTTPServerError # 501
|
203
|
+
HAS_BODY = true
|
204
|
+
end
|
205
|
+
class HTTPBadGateway < HTTPServerError # 502
|
206
|
+
HAS_BODY = true
|
207
|
+
end
|
208
|
+
class HTTPServiceUnavailable < HTTPServerError # 503
|
209
|
+
HAS_BODY = true
|
210
|
+
end
|
211
|
+
class HTTPGatewayTimeout < HTTPServerError # 504
|
212
|
+
HAS_BODY = true
|
213
|
+
end
|
214
|
+
HTTPGatewayTimeOut = HTTPGatewayTimeout
|
215
|
+
class HTTPVersionNotSupported < HTTPServerError # 505
|
216
|
+
HAS_BODY = true
|
217
|
+
end
|
218
|
+
class HTTPVariantAlsoNegotiates < HTTPServerError # 506
|
219
|
+
HAS_BODY = true
|
220
|
+
end
|
221
|
+
class HTTPInsufficientStorage < HTTPServerError # 507 - RFC 4918
|
222
|
+
HAS_BODY = true
|
223
|
+
end
|
224
|
+
class HTTPLoopDetected < HTTPServerError # 508 - RFC 5842
|
225
|
+
HAS_BODY = true
|
226
|
+
end
|
227
|
+
# 509 Bandwidth Limit Exceeded - Apache bw/limited extension
|
228
|
+
class HTTPNotExtended < HTTPServerError # 510 - RFC 2774
|
229
|
+
HAS_BODY = true
|
230
|
+
end
|
231
|
+
class HTTPNetworkAuthenticationRequired < HTTPServerError # 511 - RFC 6585
|
232
|
+
HAS_BODY = true
|
233
|
+
end
|
234
|
+
|
235
|
+
# :startdoc:
|
229
236
|
end
|
230
237
|
|
231
238
|
class Net::HTTPResponse
|
@@ -303,5 +310,3 @@ class Net::HTTPResponse
|
|
303
310
|
'511' => Net::HTTPNetworkAuthenticationRequired,
|
304
311
|
}
|
305
312
|
end
|
306
|
-
|
307
|
-
# :startdoc:
|