Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Multi part Range needs Multi Part responses. #313

tschak909 opened this Issue Nov 9, 2012 · 5 comments


None yet
4 participants


I am trying to implement mp4/aac streaming to iOS devices, and they require a multi part range to be sent as part of the headers, which in turn requires a multi part response. I saw no clear way on how to do this in Cowboy. Is there a way to be able to do this?

I have pasted the relevant piece of the HTTP specification below:

19.2 Internet Media Type multipart/byteranges

When an HTTP 206 (Partial Content) response message includes the content of multiple ranges (a response to a request for multiple non-overlapping ranges), these are transmitted as a multipart message-body. The media type for this purpose is called "multipart/byteranges".

The multipart/byteranges media type includes two or more parts, each with its own Content-Type and Content-Range fields. The required boundary parameter specifies the boundary string used to separate each body-part.

   Media Type name:         multipart
   Media subtype name:      byteranges
   Required parameters:     boundary
   Optional parameters:     none
   Encoding considerations: only "7bit", "8bit", or "binary" are
   Security considerations: none

For example:

HTTP/1.1 206 Partial Content Date: Wed, 15 Nov 1995 06:25:24 GMT Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT Content-type: multipart/byteranges; boundary=THIS_STRING_SEPARATES

--THIS_STRING_SEPARATES Content-type: application/pdf Content-range: bytes 500-999/8000

...the first range... --THIS_STRING_SEPARATES Content-type: application/pdf Content-range: bytes 7000-7999/8000

...the second range --THIS_STRING_SEPARATES--

  1) Additional CRLFs may precede the first boundary string in the
  2) Although RFC 2046 [40] permits the boundary string to be
     quoted, some existing implementations handle a quoted boundary
     string incorrectly.
  3) A number of browsers and servers were coded to an early draft
     of the byteranges specification to use a media type of
     multipart/x-byteranges, which is almost, but not quite
     compatible with the version documented in HTTP/1.1.

rflynn commented Nov 9, 2012

i also need this


essen commented Nov 9, 2012

Ahah looks like I totally forgot about multipart replies. It'll take a long time to get it done if I have to. If you can, try to at least do a temporary solution for your needs and open a PR with what you did so we can discuss.

@fishcakez fishcakez referenced this issue in ninenines/ranch Mar 29, 2013


Add Transport:sendfile/4,/5 #41

benoitc commented Jun 8, 2013

what's the status about that ?


essen commented Jun 8, 2013

Nothing happened.


essen commented Feb 20, 2014


cowlib now features functions to create multipart responses. It's not documented yet but the tests should be easy enough to understand: https://github.com/extend/cowlib/blob/master/src/cow_multipart.erl#L341 - It should be easy to use and also easy to stream multipart content to the user.

Of course as with everything, feedback is appreciated!

Closing this as this is technically done, please open a ticket on the cowlib repository if you need help/find issues. Thanks!

@essen essen closed this Feb 20, 2014

@bjfletcher bjfletcher referenced this issue in playframework/playframework Jul 20, 2015


Added range request support #4865

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment