diff 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
line wrap: on
line diff
--- a/mercurial/hgweb/common.py	Tue Mar 08 15:36:56 2011 -0500
+++ b/mercurial/hgweb/common.py	Sat Feb 06 04:27:28 2010 -0600
@@ -78,6 +78,23 @@
         self.message = message
         self.headers = headers
 
+class continuereader(object):
+    def __init__(self, f, write):
+        self.f = f
+        self._write = write
+        self.continued = False
+
+    def read(self, amt=-1):
+        if not self.continued:
+            self.continued = True
+            self._write('HTTP/1.1 100 Continue\r\n\r\n')
+        return self.f.read(amt)
+
+    def __getattr__(self, attr):
+        if attr in ('close', 'readline', 'readlines', '__iter__'):
+            return getattr(self.f, attr)
+        raise AttributeError()
+
 def _statusmessage(code):
     from BaseHTTPServer import BaseHTTPRequestHandler
     responses = BaseHTTPRequestHandler.responses