i want to add Transfer-Encoding: chunked
header to the file that i'm outputing (its just generated plain text), but when i add:
header("Transfer-Encoding: chunked");
flush();
the browser doesn't want to open the file.
The webpage at ... might be temporarily down or it may have moved permanently to a new web address.
what i need to do for it to work?
To enable chunked transfer encoding, set the value for AspEnableChunkedEncoding to True for the site, the server, or the virtual directory that you want to enable chunked transfer encoding for: Open a command prompt. Change to the Inetpub\Adminscripts folder.
Chunked transfer encoding allows a server to maintain an HTTP persistent connection for dynamically generated content. In this case, the HTTP Content-Length header cannot be used to delimit the content and the next HTTP request/response, as the content size is not yet known.
Try adding "&headers=false" to your request. That should shorten it up and cause the response to be less likely to be chunked. Also, are you sending a HTTP/1.1 or HTTP/1.0 request? Try sending a HTTP/1.0 if your device cannot handle a HTTP/1.1 request.
You need to send the Content-Length
with every chunk you send. Look at Wikipedia for a first impression, how a chunked encoding looks like. Its not that trivial and in many cases its oversized.
Update:
First you send the headers, because they must always send before any content (also with chunked encoding). Then you send (for every chunk) the size (in hexadecimal) followed by the content. Remember flush()
after every chunk. At last you must send a zero-size chunk to make sure, that the connection get closed properly.
Its not tested, but something like this
header("Transfer-Encoding: chunked");
echo "5\r\n";
echo "Hello";
echo "\r\n\r\n";
flush();
echo "5\r\n";
echo "World";
echo "\r\n";
flush();
echo "0\r\n\r\n";
flush();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With