Revision b3660886 lib/http/__init__.py

b/lib/http/__init__.py
61 61
HTTP_CONTENT_LENGTH = "Content-Length"
62 62
HTTP_CONNECTION = "Connection"
63 63
HTTP_KEEP_ALIVE = "Keep-Alive"
64
HTTP_WWW_AUTHENTICATE = "WWW-Authenticate"
65
HTTP_AUTHORIZATION = "Authorization"
66
HTTP_AUTHENTICATION_INFO = "Authentication-Info"
67
HTTP_ALLOW = "Allow"
64 68

  
65 69
_SSL_UNEXPECTED_EOF = "Unexpected EOF"
66 70

  
......
118 122

  
119 123

  
120 124
class HttpBadRequest(HttpException):
125
  """400 Bad Request
126

  
127
  RFC2616, 10.4.1: The request could not be understood by the server due to
128
  malformed syntax. The client SHOULD NOT repeat the request without
129
  modifications.
130

  
131
  """
121 132
  code = 400
122 133

  
123 134

  
135
class HttpUnauthorized(HttpException):
136
  """401 Unauthorized
137

  
138
  RFC2616, section 10.4.2: The request requires user authentication. The
139
  response MUST include a WWW-Authenticate header field (section 14.47)
140
  containing a challenge applicable to the requested resource.
141

  
142
  """
143
  code = 401
144

  
145

  
124 146
class HttpForbidden(HttpException):
147
  """403 Forbidden
148

  
149
  RFC2616, 10.4.4: The server understood the request, but is refusing to
150
  fulfill it.  Authorization will not help and the request SHOULD NOT be
151
  repeated.
152

  
153
  """
125 154
  code = 403
126 155

  
127 156

  
128 157
class HttpNotFound(HttpException):
158
  """404 Not Found
159

  
160
  RFC2616, 10.4.5: The server has not found anything matching the Request-URI.
161
  No indication is given of whether the condition is temporary or permanent.
162

  
163
  """
129 164
  code = 404
130 165

  
131 166

  
167
class HttpMethodNotAllowed(HttpException):
168
  """405 Method Not Allowed
169

  
170
  RFC2616, 10.4.6: The method specified in the Request-Line is not allowed for
171
  the resource identified by the Request-URI. The response MUST include an
172
  Allow header containing a list of valid methods for the requested resource.
173

  
174
  """
175
  code = 405
176

  
177

  
178
class HttpRequestTimeout(HttpException):
179
  """408 Request Timeout
180

  
181
  RFC2616, 10.4.9: The client did not produce a request within the time that
182
  the server was prepared to wait. The client MAY repeat the request without
183
  modifications at any later time.
184

  
185
  """
186
  code = 408
187

  
188

  
189
class HttpConflict(HttpException):
190
  """409 Conflict
191

  
192
  RFC2616, 10.4.10: The request could not be completed due to a conflict with
193
  the current state of the resource. This code is only allowed in situations
194
  where it is expected that the user might be able to resolve the conflict and
195
  resubmit the request.
196

  
197
  """
198
  code = 409
199

  
200

  
132 201
class HttpGone(HttpException):
202
  """410 Gone
203

  
204
  RFC2616, 10.4.11: The requested resource is no longer available at the server
205
  and no forwarding address is known. This condition is expected to be
206
  considered permanent.
207

  
208
  """
133 209
  code = 410
134 210

  
135 211

  
136 212
class HttpLengthRequired(HttpException):
213
  """411 Length Required
214

  
215
  RFC2616, 10.4.12: The server refuses to accept the request without a defined
216
  Content-Length. The client MAY repeat the request if it adds a valid
217
  Content-Length header field containing the length of the message-body in the
218
  request message.
219

  
220
  """
137 221
  code = 411
138 222

  
139 223

  
224
class HttpPreconditionFailed(HttpException):
225
  """412 Precondition Failed
226

  
227
  RFC2616, 10.4.13: The precondition given in one or more of the request-header
228
  fields evaluated to false when it was tested on the server.
229

  
230
  """
231
  code = 412
232

  
233

  
140 234
class HttpInternalError(HttpException):
235
  """500 Internal Server Error
236

  
237
  RFC2616, 10.5.1: The server encountered an unexpected condition which
238
  prevented it from fulfilling the request.
239

  
240
  """
141 241
  code = 500
142 242

  
143 243

  
144 244
class HttpNotImplemented(HttpException):
245
  """501 Not Implemented
246

  
247
  RFC2616, 10.5.2: The server does not support the functionality required to
248
  fulfill the request.
249

  
250
  """
145 251
  code = 501
146 252

  
147 253

  
148 254
class HttpServiceUnavailable(HttpException):
255
  """503 Service Unavailable
256

  
257
  RFC2616, 10.5.4: The server is currently unable to handle the request due to
258
  a temporary overloading or maintenance of the server.
259

  
260
  """
149 261
  code = 503
150 262

  
151 263

  
152 264
class HttpVersionNotSupported(HttpException):
265
  """505 HTTP Version Not Supported
266

  
267
  RFC2616, 10.5.6: The server does not support, or refuses to support, the HTTP
268
  protocol version that was used in the request message.
269

  
270
  """
153 271
  code = 505
154 272

  
155 273

  

Also available in: Unified diff