comparison mercurial/hgweb/request.py @ 7180:a42d27bc809d

hgweb: be sure to drain request data even in early error conditions Thanks to Mads Kiilerich with noticing this. The hg client can only read data after all the sent data has been read, so we have to read all the request data even if we're not going to do anything with it (in error conditions). This is not easy to fix in the client, because we're using Python's httplib, which is strictly stateful. Abstracted the draining into a separate method.
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Mon, 20 Oct 2008 10:15:26 +0200
parents 0dbb56e90a71
children a3d7f99c23c0
comparison
equal deleted inserted replaced
7179:3d080733a339 7180:a42d27bc809d
5 # 5 #
6 # This software may be used and distributed according to the terms 6 # This software may be used and distributed according to the terms
7 # of the GNU General Public License, incorporated herein by reference. 7 # of the GNU General Public License, incorporated herein by reference.
8 8
9 import socket, cgi, errno 9 import socket, cgi, errno
10 from mercurial import util
10 from common import ErrorResponse, statusmessage 11 from common import ErrorResponse, statusmessage
11 12
12 shortcuts = { 13 shortcuts = {
13 'cl': [('cmd', ['changelog']), ('rev', None)], 14 'cl': [('cmd', ['changelog']), ('rev', None)],
14 'sl': [('cmd', ['shortlog']), ('rev', None)], 15 'sl': [('cmd', ['shortlog']), ('rev', None)],
54 def __iter__(self): 55 def __iter__(self):
55 return iter([]) 56 return iter([])
56 57
57 def read(self, count=-1): 58 def read(self, count=-1):
58 return self.inp.read(count) 59 return self.inp.read(count)
60
61 def drain(self):
62 '''need to read all data from request, httplib is half-duplex'''
63 length = int(self.env.get('CONTENT_LENGTH', 0))
64 for s in util.filechunkiter(self.inp, limit=length):
65 pass
59 66
60 def respond(self, status, type=None, filename=None, length=0): 67 def respond(self, status, type=None, filename=None, length=0):
61 if self._start_response is not None: 68 if self._start_response is not None:
62 69
63 self.httphdr(type, filename, length) 70 self.httphdr(type, filename, length)