HTTP chunk Transfer-Encoding
brueckd at tbye.com
brueckd at tbye.com
Thu Feb 28 10:40:58 EST 2002
On Thu, 28 Feb 2002, Francis Meyvis wrote:
> Is there some python source that sends chunked packets (RFC 2616) in
> the SimpleHTTPServer or BaseHTTPServer?
> Or do you know where to find snippet of code that can split up
> file to send them in chunk format?
Hi Francis, For curiosity's sake, why do you want to split a file and
transfer it using the chunked encoding? It's most often used when the
server side doesn't know the length of the file (dynamically generated
content), which wouldn't be the case if you already have the file and want
to split it up. It's more work for both the client and the server...
Anyway, the end of the HTTP spec has psuedo code for reading a chunked
message, and generating one is even easier: your message body is the size
of the chunk (in hex) + CRLF + the chunk data + CRLF. Repeat until you
have no more data, and write out a "0" + CRLF + CRLF. The spec lets you
write out some entity headers after the 0-length chunk (and before the
final CRLF) but these are evil and should be avoided if you can help it.
-Dave
More information about the Python-list
mailing list