chiark / gitweb /
hippotat: Don't set an explicit `Content-Length'.
[hippotat.git] / hippotat
index 200cf3a2a4b333ba797c7b4d36719289687209ab..97d40a781c11866869c328fa21526fe472a58413 100755 (executable)
--- a/hippotat
+++ b/hippotat
@@ -43,7 +43,12 @@ class GeneralResponseConsumer(twisted.internet.protocol.Protocol):
     self._log(DBG.HTTP_CTRL, 'connectionMade')
 
   def connectionLostOK(self, reason):
-    return reason.check(twisted.web.client.ResponseDone)
+    return (reason.check(twisted.web.client.ResponseDone) or
+            reason.check(twisted.web.client.PotentialDataLoss))
+    # twisted.web.client.PotentialDataLoss is an entirely daft
+    # exception.  It will occur every time if the origin server does
+    # not provide a Content-Length.  (hippotatd does, of course, but
+    # the HTTP transaction might be proxied.)
 
 class ResponseConsumer(GeneralResponseConsumer):
   def __init__(self, cl, req, resp):
@@ -218,8 +223,7 @@ class Client():
       cl.log(DBG.HTTP_FULL, 'requesting: ' + str(mime))
 
       hh = { 'User-Agent': ['hippotat'],
-             'Content-Type': ['multipart/form-data; boundary="b"'],
-             'Content-Length': [str(len(mime))] }
+             'Content-Type': ['multipart/form-data; boundary="b"'] }
 
       bytesreader = io.BytesIO(mime)
       producer = twisted.web.client.FileBodyProducer(bytesreader)