469,282 Members | 2,025 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

BaseHTTPServer issues

I've just now submitted two issues to the issue tracker:
1491 BaseHTTPServer incorrectly implements response code 100

RFC 2616 sec 8.2.3 states, "An origin server that sends a 100
(Continue) response MUST ultimately send a final status code, once the
request body is received and processed, unless it terminates the
transport connection prematurely." The obvious way to do this is to
invoke the 'send_response' method twice, once with a code of 100, then
with the final code. However, BaseHTTPServer will always send two
headers ('Server' and 'Date') when it send a response. One possible
fix is to add an option to the method to suppress sending headers;
another is to add the following code to the 'send_response' method,
immediately prior to the calls to 'self.send_header':

if code == 100:
return

The more paranoid among us may wish to use this code instead:

if code == 100:
expectation = self.headers.get('Expect', "")
if expectation.lower() == '100-continue':
return
1492 BaseHTTPServer hard-codes Content-Type for error messages

The send_error method always sends a Content-Type of 'text/html'.
Other content types are both possible and desirable. For example,
someone writing a REST server might wish to send XML error messages.
Following the example of DEFAULT_ERROR_MESSAGE, I propose adding the
following in the appropriate places:

91a92,94
# Default error content-type
DEFAULT_ERROR_TYPE = 'text/html'
345c348
< self.send_header("Content-Type", "text/html")
---
self.send_header("Content-Type", error_message_type)
351a355
error_message_type = DEFAULT_ERROR_TYPE
Nov 23 '07 #1
0 922

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Joshua W. Biagio | last post: by
1 post views Thread by Yin | last post: by
3 posts views Thread by paul koelle | last post: by
4 posts views Thread by amfr | last post: by
reply views Thread by Jeff Gercken | last post: by
reply views Thread by Ron Garret | last post: by
13 posts views Thread by Ron Garret | last post: by
3 posts views Thread by Ron Garret | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.