6 messages in com.googlegroups.pylons-discussRe: Serving Files w/ multipart ranges
FromSent OnAttachments
EricHolmberg24 Mar 2008 15:58 
Ian Bicking24 Mar 2008 16:01 
EricHolmberg24 Mar 2008 16:29 
Ian Bicking24 Mar 2008 16:33 
Deron Meranda24 Mar 2008 23:37 
EricHolmberg25 Mar 2008 09:24 
Subject:Re: Serving Files w/ multipart ranges
From:Deron Meranda (dero@public.gmane.org)
Date:03/24/2008 11:37:32 PM
List:com.googlegroups.pylons-discuss

On Mon, Mar 24, 2008 at 7:34 PM, Ian Bicking
<ianb@public.gmane.org> wrote:

Would you know of any Python example code for the MIME multipart/ byteranges encoding for HTTP off the top of your head? I'll take a look at CherryPy which I believe supports it and look into MimeWriter.

I've never actually heard of multipart/byteranges, so no, I've never seen anything about it. The email module has a bunch of MIME multipart handling. Even if it doesn't have specific byteranges support it can probably construct that.

This may or may not be useful, but I wrote a bunch of code which correctly handles the difficult part of multipart/byteranges and have been using it in real production systems for a while now.

It's not integrated into any particular web platform, but should be easy enough to incorporate into your own code. See

http://deron.meranda.us/python/httpheader/

There's some example code on that page as well which shows you how to deal with HTTP range requests correctly.

If you want to know more, specifically look at the function parse_range_header() and the classes range_set and range_spec. This is all coded to precisely and comprehensively match the RFC spec. And if you haven't read the RFC closely, I highly recommend you do. There are some "surprises" in how byte ranges work that aren't immediately obvious.