Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a2b05986
Commit
a2b05986
authored
Sep 18, 2004
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #1025790: Add status code constants to httplib.
parent
ad436719
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
227 additions
and
13 deletions
+227
-13
Doc/lib/libhttplib.tex
Doc/lib/libhttplib.tex
+162
-10
Lib/httplib.py
Lib/httplib.py
+62
-3
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Doc/lib/libhttplib.tex
View file @
a2b05986
...
...
@@ -24,16 +24,6 @@ that use HTTP and HTTPS.
to the online docstrings for usage.
\end{notice}
The constants defined in this module are:
\begin{datadesc}
{
HTTP
_
PORT
}
The default port for the HTTP protocol (always
\code
{
80
}
).
\end{datadesc}
\begin{datadesc}
{
HTTPS
_
PORT
}
The default port for the HTTPS protocol (always
\code
{
443
}
).
\end{datadesc}
The module provides the following classes:
\begin{classdesc}
{
HTTPConnection
}{
host
\optional
{
, port
}}
...
...
@@ -135,6 +125,168 @@ HTTP status code that we don't understand.
\versionadded
{
2.0
}
\end{excdesc}
The constants defined in this module are:
\begin{datadesc}
{
HTTP
_
PORT
}
The default port for the HTTP protocol (always
\code
{
80
}
).
\end{datadesc}
\begin{datadesc}
{
HTTPS
_
PORT
}
The default port for the HTTPS protocol (always
\code
{
443
}
).
\end{datadesc}
and also the following constants for integer status codes:
\begin{tableiii}
{
l|c|l
}{
constant
}{
Constant
}{
Value
}{
Definition
}
\lineiii
{
CONTINUE
}{
\code
{
100
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.1.1
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1.1
}}
\lineiii
{
SWITCHING
_
PROTOCOLS
}{
\code
{
101
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.1.2
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1.2
}}
\lineiii
{
PROCESSING
}{
\code
{
102
}}
{
WEBDAV,
\ulink
{
RFC 2518, Section 10.1
}
{
http://www.webdav.org/specs/rfc2518.htm#STATUS
_
102
}}
\lineiii
{
OK
}{
\code
{
200
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.2.1
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1
}}
\lineiii
{
CREATED
}{
\code
{
201
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.2.2
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.2
}}
\lineiii
{
ACCEPTED
}{
\code
{
202
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.2.3
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.3
}}
\lineiii
{
NON
_
AUTHORITATIVE
_
INFORMATION
}{
\code
{
203
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.2.4
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.4
}}
\lineiii
{
NO
_
CONTENT
}{
\code
{
204
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.2.5
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.5
}}
\lineiii
{
RESET
_
CONTENT
}{
\code
{
205
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.2.6
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.6
}}
\lineiii
{
PARTIAL
_
CONTENT
}{
\code
{
206
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.2.7
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.7
}}
\lineiii
{
MULTI
_
STATUS
}{
\code
{
207
}}
{
WEBDAV
\ulink
{
RFC 2518, Section 10.2
}
{
http://www.webdav.org/specs/rfc2518.htm#STATUS
_
207
}}
\lineiii
{
IM
_
USED
}{
\code
{
226
}}
{
Delta encoding in HTTP,
\rfc
{
3229
}
, Section 10.4.1
}
\lineiii
{
MULTIPLE
_
CHOICES
}{
\code
{
300
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.3.1
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.1
}}
\lineiii
{
MOVED
_
PERMANENTLY
}{
\code
{
301
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.3.2
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2
}}
\lineiii
{
FOUND
}{
\code
{
302
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.3.3
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.3
}}
\lineiii
{
SEE
_
OTHER
}{
\code
{
303
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.3.4
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4
}}
\lineiii
{
NOT
_
MODIFIED
}{
\code
{
304
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.3.5
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5
}}
\lineiii
{
USE
_
PROXY
}{
\code
{
305
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.3.6
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.6
}}
\lineiii
{
TEMPORARY
_
REDIRECT
}{
\code
{
307
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.3.8
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.8
}}
\lineiii
{
BAD
_
REQUEST
}{
\code
{
400
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.1
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1
}}
\lineiii
{
UNAUTHORIZED
}{
\code
{
401
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.2
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2
}}
\lineiii
{
PAYMENT
_
REQUIRED
}{
\code
{
402
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.3
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.3
}}
\lineiii
{
FORBIDDEN
}{
\code
{
403
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.4
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.4
}}
\lineiii
{
NOT
_
FOUND
}{
\code
{
404
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.5
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5
}}
\lineiii
{
METHOD
_
NOT
_
ALLOWED
}{
\code
{
405
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.6
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.6
}}
\lineiii
{
NOT
_
ACCEPTABLE
}{
\code
{
406
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.7
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.7
}}
\lineiii
{
PROXY
_
AUTHENTICATION
_
REQUIRED
}
{
\code
{
407
}}{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.8
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.8
}}
\lineiii
{
REQUEST
_
TIMEOUT
}{
\code
{
408
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.9
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.9
}}
\lineiii
{
CONFLICT
}{
\code
{
409
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.10
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.10
}}
\lineiii
{
GONE
}{
\code
{
410
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.11
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.11
}}
\lineiii
{
LENGTH
_
REQUIRED
}{
\code
{
411
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.12
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.12
}}
\lineiii
{
PRECONDITION
_
FAILED
}{
\code
{
412
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.13
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.13
}}
\lineiii
{
REQUEST
_
ENTITY
_
TOO
_
LARGE
}
{
\code
{
413
}}{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.14
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.14
}}
\lineiii
{
REQUEST
_
URI
_
TOO
_
LONG
}{
\code
{
414
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.15
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.15
}}
\lineiii
{
UNSUPPORTED
_
MEDIA
_
TYPE
}{
\code
{
415
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.16
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.16
}}
\lineiii
{
REQUESTED
_
RANGE
_
NOT
_
SATISFIABLE
}{
\code
{
416
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.17
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.17
}}
\lineiii
{
EXPECTATION
_
FAILED
}{
\code
{
417
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.4.18
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.18
}}
\lineiii
{
UNPROCESSABLE
_
ENTITY
}{
\code
{
422
}}
{
WEBDAV,
\ulink
{
RFC 2518, Section 10.3
}
{
http://www.webdav.org/specs/rfc2518.htm#STATUS
_
422
}}
\lineiii
{
LOCKED
}{
\code
{
423
}}
{
WEBDAV
\ulink
{
RFC 2518, Section 10.4
}
{
http://www.webdav.org/specs/rfc2518.htm#STATUS
_
423
}}
\lineiii
{
FAILED
_
DEPENDENCY
}{
\code
{
424
}}
{
WEBDAV,
\ulink
{
RFC 2518, Section 10.5
}
{
http://www.webdav.org/specs/rfc2518.htm#STATUS
_
424
}}
\lineiii
{
UPGRADE
_
REQUIRED
}{
\code
{
426
}}
{
HTTP Upgrade to TLS,
\rfc
{
2817
}
, Section 6
}
\lineiii
{
INTERNAL
_
SERVER
_
ERROR
}{
\code
{
500
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.5.1
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1
}}
\lineiii
{
NOT
_
IMPLEMENTED
}{
\code
{
501
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.5.2
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.2
}}
\lineiii
{
BAD
_
GATEWAY
}{
\code
{
502
}}
{
HTTP/1.1
\ulink
{
RFC 2616, Section 10.5.3
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.3
}}
\lineiii
{
SERVICE
_
UNAVAILABLE
}{
\code
{
503
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.5.4
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.4
}}
\lineiii
{
GATEWAY
_
TIMEOUT
}{
\code
{
504
}}
{
HTTP/1.1
\ulink
{
RFC 2616, Section 10.5.5
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.5
}}
\lineiii
{
HTTP
_
VERSION
_
NOT
_
SUPPORTED
}{
\code
{
505
}}
{
HTTP/1.1,
\ulink
{
RFC 2616, Section 10.5.6
}
{
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.6
}}
\lineiii
{
INSUFFICIENT
_
STORAGE
}{
\code
{
507
}}
{
WEBDAV,
\ulink
{
RFC 2518, Section 10.6
}
{
http://www.webdav.org/specs/rfc2518.htm#STATUS
_
507
}}
\lineiii
{
NOT
_
EXTENDED
}{
\code
{
510
}}
{
An HTTP Extension Framework,
\rfc
{
2774
}
, Section 7
}
\end{tableiii}
\subsection
{
HTTPConnection Objects
\label
{
httpconnection-objects
}}
...
...
Lib/httplib.py
View file @
a2b05986
...
...
@@ -93,6 +93,66 @@ _CS_IDLE = 'Idle'
_CS_REQ_STARTED
=
'Request-started'
_CS_REQ_SENT
=
'Request-sent'
# status codes
# informational
CONTINUE
=
100
SWITCHING_PROTOCOLS
=
101
PROCESSING
=
102
# successful
OK
=
200
CREATED
=
201
ACCEPTED
=
202
NON_AUTHORITATIVE_INFORMATION
=
203
NO_CONTENT
=
204
RESET_CONTENT
=
205
PARTIAL_CONTENT
=
206
MULTI_STATUS
=
207
IM_USED
=
226
# redirection
MULTIPLE_CHOICES
=
300
MOVED_PERMANENTLY
=
301
FOUND
=
302
SEE_OTHER
=
303
NOT_MODIFIED
=
304
USE_PROXY
=
305
TEMPORARY_REDIRECT
=
307
# client error
BAD_REQUEST
=
400
UNAUTHORIZED
=
401
PAYMENT_REQUIRED
=
402
FORBIDDEN
=
403
NOT_FOUND
=
404
METHOD_NOT_ALLOWED
=
405
NOT_ACCEPTABLE
=
406
PROXY_AUTHENTICATION_REQUIRED
=
407
REQUEST_TIMEOUT
=
408
CONFLICT
=
409
GONE
=
410
LENGTH_REQUIRED
=
411
PRECONDITION_FAILED
=
412
REQUEST_ENTITY_TOO_LARGE
=
413
REQUEST_URI_TOO_LONG
=
414
UNSUPPORTED_MEDIA_TYPE
=
415
REQUESTED_RANGE_NOT_SATISFIABLE
=
416
EXPECTATION_FAILED
=
417
UNPROCESSABLE_ENTITY
=
422
LOCKED
=
423
FAILED_DEPENDENCY
=
424
UPGRADE_REQUIRED
=
426
# server error
INTERNAL_SERVER_ERROR
=
500
NOT_IMPLEMENTED
=
501
BAD_GATEWAY
=
502
SERVICE_UNAVAILABLE
=
503
GATEWAY_TIMEOUT
=
504
HTTP_VERSION_NOT_SUPPORTED
=
505
INSUFFICIENT_STORAGE
=
507
NOT_EXTENDED
=
510
class
HTTPMessage
(
mimetools
.
Message
):
def
addheader
(
self
,
key
,
value
):
...
...
@@ -271,7 +331,7 @@ class HTTPResponse:
# read until we get a non-100 response
while
True
:
version
,
status
,
reason
=
self
.
_read_status
()
if
status
!=
100
:
if
status
!=
CONTINUE
:
break
# skip the header from the 100 response
while
True
:
...
...
@@ -329,8 +389,7 @@ class HTTPResponse:
self
.
length
=
None
# does the body have a fixed length? (of zero)
if
(
status
==
204
or
# No Content
status
==
304
or
# Not Modified
if
(
status
==
NO_CONTENT
or
status
==
NOT_MODIFIED
or
100
<=
status
<
200
or
# 1xx codes
self
.
_method
==
'HEAD'
):
self
.
length
=
0
...
...
Misc/ACKS
View file @
a2b05986
...
...
@@ -161,6 +161,7 @@ Eugene Dvurechenski
Maxim Dzumanenko
Hans Eckardt
Grant Edwards
Andrew Eland
Lance Ellinghaus
David Ely
Jeff Epler
...
...
Misc/NEWS
View file @
a2b05986
...
...
@@ -22,6 +22,8 @@ Extension modules
Library
-------
- httplib now offers symbolic constants for the HTTP status codes.
- SF bug #1028306: Trying to compare a ``datetime.date`` to a
``datetime.datetime`` mistakenly compared only the year, month and day.
Now it acts like a mixed-type comparison: ``False`` for ``==``,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment