File: httpstatus.rbs

package info (click to toggle)
ruby-webrick 1.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 748 kB
  • sloc: ruby: 7,783; sh: 4; makefile: 4
file content (255 lines) | stat: -rw-r--r-- 6,306 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
module WEBrick
  #
  # This module is used to manager HTTP status codes.
  #
  # See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for more
  # information.
  module HTTPStatus
    #
    # Root of the HTTP status class hierarchy
    class Status < StandardError
      attr_reader self.code: Integer

      attr_reader self.reason_phrase: String

      # Returns the HTTP status code
      def code: () -> Integer

      # Returns the HTTP status description
      def reason_phrase: () -> String

      alias to_i code
    end

    # Root of the HTTP info statuses
    class Info < Status
    end

    # Root of the HTTP success statuses
    class Success < Status
    end

    # Root of the HTTP redirect statuses
    class Redirect < Status
    end

    # Root of the HTTP error statuses
    class Error < Status
    end

    # Root of the HTTP client error statuses
    class ClientError < Error
    end

    # Root of the HTTP server error statuses
    class ServerError < Error
    end

    class EOFError < StandardError
    end

    # HTTP status codes and descriptions
    StatusMessage: Hash[Integer, String]

    # Maps a status code to the corresponding Status class
    CodeToError: Hash[Integer, singleton(Status)]

    # WEBrick::HTTPStatus::constants.grep(/\ARC_/).map{"#{_1}: #{WEBrick::HTTPStatus.const_get(_1)}"}

    RC_CONTINUE: 100
    RC_SWITCHING_PROTOCOLS: 101
    RC_OK: 200
    RC_CREATED: 201
    RC_ACCEPTED: 202
    RC_NON_AUTHORITATIVE_INFORMATION: 203
    RC_NO_CONTENT: 204
    RC_RESET_CONTENT: 205
    RC_PARTIAL_CONTENT: 206
    RC_MULTI_STATUS: 207
    RC_MULTIPLE_CHOICES: 300
    RC_MOVED_PERMANENTLY: 301
    RC_FOUND: 302
    RC_SEE_OTHER: 303
    RC_NOT_MODIFIED: 304
    RC_USE_PROXY: 305
    RC_TEMPORARY_REDIRECT: 307
    RC_BAD_REQUEST: 400
    RC_UNAUTHORIZED: 401
    RC_PAYMENT_REQUIRED: 402
    RC_FORBIDDEN: 403
    RC_NOT_FOUND: 404
    RC_METHOD_NOT_ALLOWED: 405
    RC_NOT_ACCEPTABLE: 406
    RC_PROXY_AUTHENTICATION_REQUIRED: 407
    RC_REQUEST_TIMEOUT: 408
    RC_CONFLICT: 409
    RC_GONE: 410
    RC_PRECONDITION_FAILED: 412
    RC_LENGTH_REQUIRED: 411
    RC_REQUEST_ENTITY_TOO_LARGE: 413
    RC_REQUEST_URI_TOO_LARGE: 414
    RC_UNSUPPORTED_MEDIA_TYPE: 415
    RC_EXPECTATION_FAILED: 417
    RC_UNPROCESSABLE_ENTITY: 422
    RC_LOCKED: 423
    RC_FAILED_DEPENDENCY: 424
    RC_REQUEST_RANGE_NOT_SATISFIABLE: 416
    RC_UPGRADE_REQUIRED: 426
    RC_PRECONDITION_REQUIRED: 428
    RC_TOO_MANY_REQUESTS: 429
    RC_REQUEST_HEADER_FIELDS_TOO_LARGE: 431
    RC_UNAVAILABLE_FOR_LEGAL_REASONS: 451
    RC_INTERNAL_SERVER_ERROR: 500
    RC_NOT_IMPLEMENTED: 501
    RC_BAD_GATEWAY: 502
    RC_SERVICE_UNAVAILABLE: 503
    RC_GATEWAY_TIMEOUT: 504
    RC_HTTP_VERSION_NOT_SUPPORTED: 505
    RC_INSUFFICIENT_STORAGE: 507
    RC_NETWORK_AUTHENTICATION_REQUIRED: 511

    # WEBrick::HTTPStatus::CodeToError.each_value.map{"class #{_1.name.split(/::/).last} < #{_1.superclass.name.split(/::/).last}\nend"}

    class Continue < Info
    end
    class SwitchingProtocols < Info
    end
    class OK < Success
    end
    class Created < Success
    end
    class Accepted < Success
    end
    class NonAuthoritativeInformation < Success
    end
    class NoContent < Success
    end
    class ResetContent < Success
    end
    class PartialContent < Success
    end
    class MultiStatus < Success
    end
    class MultipleChoices < Redirect
    end
    class MovedPermanently < Redirect
    end
    class Found < Redirect
    end
    class SeeOther < Redirect
    end
    class NotModified < Redirect
    end
    class UseProxy < Redirect
    end
    class TemporaryRedirect < Redirect
    end
    class BadRequest < ClientError
    end
    class Unauthorized < ClientError
    end
    class PaymentRequired < ClientError
    end
    class Forbidden < ClientError
    end
    class NotFound < ClientError
    end
    class MethodNotAllowed < ClientError
    end
    class NotAcceptable < ClientError
    end
    class ProxyAuthenticationRequired < ClientError
    end
    class RequestTimeout < ClientError
    end
    class Conflict < ClientError
    end
    class Gone < ClientError
    end
    class LengthRequired < ClientError
    end
    class PreconditionFailed < ClientError
    end
    class RequestEntityTooLarge < ClientError
    end
    class RequestURITooLarge < ClientError
    end
    class UnsupportedMediaType < ClientError
    end
    class RequestRangeNotSatisfiable < ClientError
    end
    class ExpectationFailed < ClientError
    end
    class UnprocessableEntity < ClientError
    end
    class Locked < ClientError
    end
    class FailedDependency < ClientError
    end
    class UpgradeRequired < ClientError
    end
    class PreconditionRequired < ClientError
    end
    class TooManyRequests < ClientError
    end
    class RequestHeaderFieldsTooLarge < ClientError
    end
    class UnavailableForLegalReasons < ClientError
    end
    class InternalServerError < ServerError
    end
    class NotImplemented < ServerError
    end
    class BadGateway < ServerError
    end
    class ServiceUnavailable < ServerError
    end
    class GatewayTimeout < ServerError
    end
    class HTTPVersionNotSupported < ServerError
    end
    class InsufficientStorage < ServerError
    end
    class NetworkAuthenticationRequired < ServerError
    end

    #
    # Returns the description corresponding to the HTTP status +code+
    #
    #   WEBrick::HTTPStatus.reason_phrase 404
    #   => "Not Found"
    def self?.reason_phrase: (Integer code) -> String

    #
    # Is +code+ an informational status?
    def self?.info?: (Integer code) -> bool

    #
    # Is +code+ a successful status?
    def self?.success?: (Integer code) -> bool

    #
    # Is +code+ a redirection status?
    def self?.redirect?: (Integer code) -> bool

    #
    # Is +code+ an error status?
    def self?.error?: (Integer code) -> bool

    #
    # Is +code+ a client error status?
    def self?.client_error?: (Integer code) -> bool

    #
    # Is +code+ a server error status?
    def self?.server_error?: (Integer code) -> bool

    #
    # Returns the status class corresponding to +code+
    #
    #   WEBrick::HTTPStatus[302]
    #   => WEBrick::HTTPStatus::NotFound
    #
    def self.[]: (Integer code) -> singleton(Status)
  end
end