Mercurial > hg
comparison mercurial/hgweb/common.py @ 13570:617a87cb7eb2
hgweb: add support for 100-continue as recommended by PEP 333.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sat, 06 Feb 2010 04:27:28 -0600 |
parents | 75f5f312df5f |
children | 0bef8f69c078 |
comparison
equal
deleted
inserted
replaced
13569:3ab3b892d223 | 13570:617a87cb7eb2 |
---|---|
75 message = _statusmessage(code) | 75 message = _statusmessage(code) |
76 Exception.__init__(self, code, message) | 76 Exception.__init__(self, code, message) |
77 self.code = code | 77 self.code = code |
78 self.message = message | 78 self.message = message |
79 self.headers = headers | 79 self.headers = headers |
80 | |
81 class continuereader(object): | |
82 def __init__(self, f, write): | |
83 self.f = f | |
84 self._write = write | |
85 self.continued = False | |
86 | |
87 def read(self, amt=-1): | |
88 if not self.continued: | |
89 self.continued = True | |
90 self._write('HTTP/1.1 100 Continue\r\n\r\n') | |
91 return self.f.read(amt) | |
92 | |
93 def __getattr__(self, attr): | |
94 if attr in ('close', 'readline', 'readlines', '__iter__'): | |
95 return getattr(self.f, attr) | |
96 raise AttributeError() | |
80 | 97 |
81 def _statusmessage(code): | 98 def _statusmessage(code): |
82 from BaseHTTPServer import BaseHTTPRequestHandler | 99 from BaseHTTPServer import BaseHTTPRequestHandler |
83 responses = BaseHTTPRequestHandler.responses | 100 responses = BaseHTTPRequestHandler.responses |
84 return responses.get(code, ('Error', 'Unknown error'))[0] | 101 return responses.get(code, ('Error', 'Unknown error'))[0] |