How to make PHP generate Chunked response

后端 未结 9 2072
渐次进展
渐次进展 2020-11-28 06:32

I googled for this problem but there is no answer for it.

I want my PHP script to generate HTTP response in chunked( http://en.wikipedia.org/wiki/Chunked_transfer_en

9条回答
  •  日久生厌
    2020-11-28 07:10

    This has gotten a little vauge... if you don't mind big assed chunks, (0x1000 octets or so), then yes, PHP will make them.

    
    

    PHP will generated the numbered sections, etc.

    If you want to send tiny little chunks, as you might do with an AJAX client... well, I've combined the OPs question, with some research on PHP.NET, and it does look like he was on to a good thing.

    $ echo -en "GET /chunked/ HTTP/1.1\r\nHost: ec\r\n\r\n" | nc localhost 80

    HTTP/1.1 200 OK
    Date: Wed, 23 May 2012 13:03:01 GMT
    Server: Apache/2.2.9 (Debian) PHP/5.3.5-1 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8o
    X-Powered-By: PHP/5.3.5-1
    Transfer-encoding: chunked
    Content-Type: text/html
    
    14
    Teachers have class.
    50
    We secure our friends not by accepting favors but by doing them.
                -- Thucydides
    48
    Vulcans never bluff.
                -- Spock, "The Doomsday Machine", stardate 4202.1
    31
    All kings is mostly rapscallions.
                -- Mark Twain
    41
    Reappraisal, n.:
        An abrupt change of mind after being found out.
    49
    He who knows, does not speak.  He who speaks, does not know.
                -- Lao Tsu
    

    Whether or not it will eventually squeeze out it out's own (incorrect) chunk count, remains to be seen... but I saw no sign of it.

    
    

提交回复
热议问题