[Python-Dev] how to debug httplib slowness

Scott Dial scott+python-dev at scottdial.com
Fri Sep 4 18:03:16 CEST 2009


Chris Withers wrote:
> - Apache in this instance responds with HTTP 1.1, even though the wget
> request was 1.0, is that allowed?
> 
> - Apache responds with a chunked response only to httplib. Why is that?
> 

I find it very confusing that you say "Apache" since your really want to
say "Coyote" which is to say "Tomcat".

Http11Processor.java at 1547:
    if (entityBody && http11 && keepAlive) {
        outputBuffer.addActiveFilter
            (outputFilters[Constants.CHUNKED_FILTER]);
        contentDelimitation = true;
        headers.addValue(
            Constants.TRANSFERENCODING).setString(Constants.CHUNKED);
    } else {
        outputBuffer.addActiveFilter
            (outputFilters[Constants.IDENTITY_FILTER]);
    }

So, as Oleg said, it's because httplib talks HTTP/1.1 and wget talks
HTTP/1.0. All HTTP/1.1 client must support chunked transfer-encoding,
and apparently Tomcat/Coyote defaults to that unless it is either an
empty message, not a HTTP/1.1 client, or the request is not to be kept
alive ("Connection: close" or no more keep-alive slots on the server).

As Simon said, changing this to do ''.join(chunks) is really the best
first step to take.

-Scott

-- 
Scott Dial
scott at scottdial.com
scodial at cs.indiana.edu


More information about the Python-Dev mailing list