Adding status code constants to httplib
Hi, Over in web-sig, we're discussing PEP 333, the Web Server Gateway Interface. Rather than defining our own set of constants for the HTTP status code integers, we thought it would be a good idea to add them to httplib, allowing other applications to benefit. I've uploaded a patch[1] to httplib.py and the corresponding documentation. Do people think this is a good idea? -- Andrew Eland (http://www.andreweland.org) [1] http://sourceforge.net/tracker/index.php?func=detail&aid=1025790&group_id=5470&atid=305470
On Friday 10 September 2004 07:45 am, Andrew Eland wrote:
Over in web-sig, we're discussing PEP 333, the Web Server Gateway Interface. Rather than defining our own set of constants for the HTTP status code integers, we thought it would be a good idea to add them to httplib,
+1 Some of us really don't remember what all the numeric codes mean, especially the ones we don't see often. -Fred -- Fred L. Drake, Jr. <fdrake at acm.org>
At 12:45 PM 9/10/04 +0100, Andrew Eland wrote:
Over in web-sig, we're discussing PEP 333, the Web Server Gateway Interface. Rather than defining our own set of constants for the HTTP status code integers, we thought it would be a good idea to add them to httplib, allowing other applications to benefit. I've uploaded a patch[1] to httplib.py and the corresponding documentation. Do people think this is a good idea?
I would also put the statuses in a dictionary, such that: status_code[BAD_GATEWAY] = "Bad Gateway" This could be accomplished via something like: status_code = dict([ (val, key.replace('_',' ').title()) for key,val in globals.items() if key==key.upper() and not key.startswith('HTTP') and not key.startswith('_') ])
Phillip J. Eby wrote:
I would also put the statuses in a dictionary, such that:
status_code[BAD_GATEWAY] = "Bad Gateway"
There's a table mapping status codes to messages on BaseHTTPRequestHandler at the moment. It could be moved into httplib to make it more publically visible. -- Andrew
[Phillip J. Eby]
I would also put the statuses in a dictionary, such that:
status_code[BAD_GATEWAY] = "Bad Gateway"
[Andrew Eland]
There's a table mapping status codes to messages on BaseHTTPRequestHandler at the moment. It could be moved into httplib to make it more publically visible.
And that mapping has 2 levels of human readable messages on it, for example 304: ('Not modified', 'Document has not changed singe given time'), I think that, since the human readable versions are seldom heeded anyway, perhaps a single message is all we need? And I'm -1 on forcing servers, particularly CGI servers, to import the client-side httplib (2.3 httplib.pyc == 42K) just to get this mapping. If the changes are not going to make it in until the next release of cpython anyway, then maybe we should just aim for a new module? Or is some version of 2.4 the target, in which case minimal patches might make it in, whereas new modules won't? Just my 0,02 euro. Alan.
Alan Kennedy wrote:
And that mapping has 2 levels of human readable messages on it, for example 304: ('Not modified', 'Document has not changed singe given time'), I think that, since the human readable versions are seldom heeded anyway, perhaps a single message is all we need?
A simple move would mean we'd have to keep both, for backwards compatability. I guess BaseHTTPRequestHandler could mix its long messages in with those in a httplib table, but it sounds ugly.
And I'm -1 on forcing servers, particularly CGI servers, to import the client-side httplib (2.3 httplib.pyc == 42K) just to get this mapping.
I think the number of people who wouldn't import httplib on speed/process size grounds is very small. If they're that worried about efficiency, they could copy and paste the table, and manage the extra development complexity. -- Andrew
Alan Kennedy wrote:
And I'm -1 on forcing servers, particularly CGI servers, to import the client-side httplib (2.3 httplib.pyc == 42K) just to get this mapping.
It might be somewhat comforting that the 2.4 httplib.pyc is only 33K. Regards, Martin
At 04:12 PM 9/10/04 +0100, Andrew Eland wrote:
Phillip J. Eby wrote:
I would also put the statuses in a dictionary, such that: status_code[BAD_GATEWAY] = "Bad Gateway"
There's a table mapping status codes to messages on BaseHTTPRequestHandler at the moment. It could be moved into httplib to make it more publically visible.
It doesn't appear to include HTTP/1.1 status codes.
FYI; status codes as exceptions; http://www.mnot.net/python/http/status.py On Sep 10, 2004, at 9:45 PM, Andrew Eland wrote:
Hi,
Over in web-sig, we're discussing PEP 333, the Web Server Gateway Interface. Rather than defining our own set of constants for the HTTP status code integers, we thought it would be a good idea to add them to httplib, allowing other applications to benefit. I've uploaded a patch[1] to httplib.py and the corresponding documentation. Do people think this is a good idea?
-- Andrew Eland (http://www.andreweland.org)
[1] http://sourceforge.net/tracker/index.php? func=detail&aid=1025790&group_id=5470&atid=305470 _______________________________________________ Web-SIG mailing list Web-SIG@python.org Web SIG: http://www.python.org/sigs/web-sig Unsubscribe: http://mail.python.org/mailman/options/web-sig/mnot%40mnot.net
-- Mark Nottingham http://www.mnot.net/
participants (6)
-
"Martin v. Löwis"
-
Alan Kennedy
-
Andrew Eland
-
Fred L. Drake, Jr.
-
Mark Nottingham
-
Phillip J. Eby