Apache 2.0.54, Enabling Chunk transfer Encoding

Posted on 2005-05-10
Last Modified: 2008-01-09
  I have Apache 2.0.54 installed in a Windows 2000 server environment.
I want to know wether it has chunked trasfer encoding enabled.If not ,how can I enable it?
I tried looking through the docs, but no avail.
I have PHP installed too.
Question by:blinker82
    LVL 19

    Expert Comment

    According to apache documentation if you use
     KeepAlive on
    directive then
    "If the client requests it, chunked encoding will be used in order to send content of unknown length over persistent connections."

    Author Comment

    yes it is ON
    But does it enable Apache Server to accept the Chunked data through say post.
    I cannot turn off the chunked encoding at the client and hence have to make sure that Apache Server has the capability to accept chunked transfer encoding and currently it does not ( Atleast the one  I have installed)
    LVL 19

    Expert Comment

    It doesn't matter which method is used GET or POST. if chunked
    it is possible that there is a config line in httpd.conf that disables chunked encoding for some browsers.
    check for example for following line
    BrowserMatch "MSIE 4\.0b2;" downgrade-1.0 force-response-1.0
    (check for other force-response-1.0 words too)

    and try to comment them

    Author Comment

    ok  I will reframe my question,
    I want to what versions of Apache Server would support accepting chunk trasnfer encoded data.
    I am Posting from Cisco Voice Gateway AS 5300 .Using VXML .I have no choice but to post using Chunk Transfer Encoding(default)
    Now when i am posting, I get a content length required error from Apache, which I assume occurs because of the chunked transfer.
    I am
    What I want to know
    1.)I am right about the reason why I get the content length required error?
    2.)I can post alright from a form which does not use chunked transfer,but  how can i test sending data using chunked transfer from a normal HTML or PHP form   to a PHP script residing on the Apache Server?
    3.)Does Apache Server support chunk trasnfer Encoding? What versions do that? I read somewhere that it has been turned of due to some security vulnerablitiy due to Chunk tranfer.Is there a Module ,which can enable that?
    I am lost.

    LVL 19

    Expert Comment

    1) yo get it because chunked encoding is disabled
    2) by defalt if you use http/1.1 client (eg. FireFox) then it will use chuncked transfer encoding. You can see it by some monitoring tools (like ethereal) in response. Transfer-Encoding: chunked header will appear on it. I tested it with and it was chucnked response.
    3) Apache 1.3 through 1.3.24, and Apache 2.0 through 2.0.36, allows remote attackers to cause a denial of service and possibly execute arbitrary code via a chunk-encoded HTTP request that causes Apache to use an incorrect size.
    If you will find version prior that versions then chuncked encoding should be enabled by default.
    LVL 19

    Expert Comment

    in CHANGES file of httpd source it is mentioned:
    "Correctly return 413 when an invalid chunk size is given on
         input.  Also modify ap_discard_request_body to not do anything
         on sub-requests or when the connection will be dropped.
         [Justin Erenkrantz]"

    It menas then you provide request without Contetn-Length header then you got content-length required error response.

    Author Comment

    ok this is my form :-
    header('Content-Transfer-Encoding: Chunked');
    <form enctype="multipart/form-data" action="http://XXX/xml/loadsound.php"  method="POST">
        Send this file: <input name="myrec" type="file"  />
        <input type="submit" value="Send File" />

     I submit this form using FireFox browser. I sniffed the packets using ethereal. It does not say that the transfer encoding is chunked .There is no header called tranfer-encoding.
    But when I sniffed packets coming from The Cisco Gateway.It was chunked.
    What changes can I make to the form above,say if i embed php make the tranfer chunked?
    LVL 19

    Accepted Solution

    I tried to send simple form with POST (on same server which supports chunked encoding ) and I don't need to provide any specific headers. Server self should decide will it send chunked or not based on browser header Accept-Encoding:
    I provide you  request/response headers of my test session:

    POST /tatweb/search.php HTTP/1.1
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3 (ax)
    Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    Accept-Language: ru,en-us;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 48



    HTTP/1.1 200 OK
    Date: Thu, 12 May 2005 07:16:55 GMT
    Server: Apache-AdvancedExtranetServer/1.3.27 (%{distribution}/8mdk) rus/PL30.17 PHP/4.3.1
    X-Powered-By: PHP/4.3.1
    Keep-Alive: timeout=15, max=99
    Connection: Keep-Alive
    Transfer-Encoding: chunked
    Content-Type: text/html; charset=windows-1251
    Vary: accept-charset

    Author Comment

    oh........ok...........actually I got the same response.........chunked
    One more thing, I am using content-type: Mulitpart/form-data as I am posting a sound file.
    It is working fine with when I post from the browser is the CISCO Voice Gateway i am posting from  ,when it says it does not have content length and just exits after that.
       I saw that from the browser also it does not get the content length ,but it accepts the post and even saves the file.
    but when I send from the Voice throws the HTTP 401.
    any suggestions?
    LVL 19

    Expert Comment

    HTTP 401 means Authentication failure.
    Is your URL protected by username/password ??

    Author Comment

    actually the erro was 411 and not 401.......I am sorry.
    And I also solved the problem. I will post the solution in a day or 2.
    Thanks ramazanyich anyways

    Author Comment

    actually I made the following change in the PHP source code.
    In file sapi/apache/php_mod4.c

    if ((retval = setup_client_block(r, REQUEST_CHUNKED_ERROR))) {
    if ((retval = setup_client_block(r, REQUEST_CHUNKED_DECHUNK))) {

    and recompiled the code.
    voila it worked !!!
    Actually the CISCO manual does give this info...........
    Thanks  ramazanyich for ur help ............i ll give u the points nonetheless........
    But this is the CORRECT ANSWER

    Author Comment

    oops I want to change the grade from B to A.How to do that?

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
    In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now