There were delimiters around the data, and the response headers included a reference to “Chunked Transfer-Encoding”. I had to look it up to find out what it was, and I had no idea how to turn it off so I posted on the Twisted Python mailing list, and got a prompt reply.
Chunked encoding has nothing to do with the content type. It is used if
you do not set a content-length header.
So, figure out your response’s length (in bytes), and set the
content-length header to that.
Aha! So this in my
http.Request handler fixed it.
# Set the content length so that we don't respond with chunked
size = len(content)
log.debug("content length is %d bytes" % size)
Well, not a fix really as there was no bug, but I wanted to rule out the chunked encoding as the source of a problem that I was seeing.