473,795 Members | 3,323 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_head er':

if code == 100:
return

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

if code == 100:
expectation = self.headers.ge t('Expect', "")
if expectation.low er() == '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_M ESSAGE, I propose adding the
following in the appropriate places:

91a92,94
# Default error content-type
DEFAULT_ERROR_T YPE = 'text/html'
345c348
< self.send_heade r("Content-Type", "text/html")
---
self.send_heade r("Content-Type", error_message_t ype)
351a355
error_message_t ype = DEFAULT_ERROR_T YPE
Nov 23 '07 #1
0 1091

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2017
by: Joshua W. Biagio | last post by:
Hello all, I am having difficulty getting the HTTP/1.1 support (i.e. pipelining and persistent connections) for the BaseHTTPServer library to work. When I change the line for the protocol in BaseHTTPServer from "HTTP/1.0" to "HTTP/1.1", the SimpleHTTPServer program can still serve directory listings and even graphics files, but it hangs when I try to browse to an HTML file. I have a directory of web pages that I use to test servers (such as...
1
1895
by: Yin | last post by:
Hello. I am using the basehttpserver to implement the HTTP protocol to serve a fairly large lexicon that I have loaded as a dictionary in python. Rather than writing a whole server, I would like to reuse the BaseHTTPserver classes. I am interested in finding a way to serve the dict without loading the whole dict into memory everytime an HTTP request is made. The dict lives in local memory when it is loaded and takes a long time to load.
3
4801
by: paul koelle | last post by:
Hi list, My ultimate goal is to have a small HTTP proxy which is able to show a message specific to clients name/ip/status then handle the original request normally either by redirecting the client, or acting as a proxy. I started with a modified version of TinyHTTPProxy postet by Suzuki Hisao somewhere in 2003 to this list and tried to extend it to my needs. It works quite well if I configure my client to use it, but using iptables...
2
6383
by: Tortelini | last post by:
I am making custom web server using HTTPServer and want to be able to access it simultaneously from different computers. To achieve multithreading, I have been experimenting with ThreadingMixIn from SocketServer, but it doesn't seem to work, when I freeze code in one instance it seems to be frozen in second one too (I experimented with time.sleep and while 1 loop). I am using python 2.4 on Windows XP. Does anyone have any suggestions? Do I...
4
3565
by: amfr | last post by:
>From the BaseHTTPServer module, how do i gget the POST or GET data sent by the client? Is it stired the the file they requested? e.g. objectname.path
0
1000
by: Jeff Gercken | last post by:
I want my http server to return a default form, regardless of the GET request, but I'm a bit of a noob and have no idea how. I'm trying to write a platform-independent captured portal for my wireless AP. This is what I have: #!/usr/bin/env python import CGIHTTPServer import BaseHTTPServer class ServerHandler(CGIHTTPServer.CGIHTTPRequestHandler): cgi_directories=
0
1355
by: Ron Garret | last post by:
I'm write a web server using BaseHTTPServer. It can't be a CGI because it has to do some weird server-push stuff as database updates come in. But I still need to process form inputs as if it were a CGI. But the cgi module only works in a CGI environment. Is there something with the equivalent functionality of cgi.FieldStorage for parsing form input in a non-CGI environment such as a BaseHTTPServer? I looked at the cgi module code but...
13
2667
by: Ron Garret | last post by:
I'm trying to figure out how to use BaseHTTPServer. Here's my little test app: ================================= #!/usr/bin/python from BaseHTTPServer import * import cgi
3
2405
by: Ron Garret | last post by:
I have a fairly large web app written in Python as a CGI fairly elaborate CGI. All of the requests go through a single CGI script which does authentication and session management and then dispatches to one of a number of handlers that generate the various pages. There is one page that is a performance bottleneck (because it is accessed automatically once a second by an XMLHTTPRequest, but that's another story). I have fixed this by...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10435
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6779
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.