chiark / gitweb /
hippotat: Don't set an explicit `Content-Length'.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 25 Sep 2017 09:29:01 +0000 (10:29 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 25 Sep 2017 10:15:48 +0000 (11:15 +0100)
It turns out (a) that the existing Twisted machinery already sets a
`Content-Length' header on `POST' submissions, (b) that it's too stupid
to notice that the caller's already set one, and (c) that nginx rejects
`POST' requests with duplicate `Content-Length' headers with `400 Bad
Request', which turns out to be surprisingly hard to debug.

Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
hippotat

index 7130f91..97d40a7 100755 (executable)
--- a/hippotat
+++ b/hippotat
@@ -223,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)