House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

cfheader Content-Range

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Chad Baloga
01/04/2012 07:50 AM

Does anyone know how to get Content-Range returned as a header response when the request has "Range: bytes=   " in it?  I added <cfheader name=Accept-Ranges" value="bytes"> but do not get the Content-Range back.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dave Watts
01/04/2012 10:26 AM

> Does anyone know how to get Content-Range returned as a header response when the request has "Range: bytes=   " in it? > I added <cfheader name=Accept-Ranges" value="bytes"> but do not get the Content-Range back. CF, like most application servers in my experience, will not honor things like this - request headers that control behavior, HTTP verbs that control behavior, etc. It's up to the developer to do this. You would have to read the range in the request, and generate a response to serve just that range, and return the appropriate headers, etc, yourself. A common example of this that I run into all the time is the use of Last-Modified in HTTP responses, and support for If-Modified-Since HTTP request headers. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsit

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Chad Baloga
01/12/2012 06:33 AM

I have come up with a solution but it is not working 100%.  It seems like the Content-Range header is not working.  I return the correct Content-Length, but it always starts at the beginning of the file.  See code below... <!--- If range is specified, then change some header info ---> <cfif StructKeyExists(GetHttpRequestData().headers, "Range")>    <!--- Range value --->    <cfset variables.range = ListLast(GetHttpRequestData().headers["Range"],"=") />      <!--- Calculate Range length --->   <cfset variables.max = ListLast(variables.range,"-")/>   <cfset variables.min = ListFirst(variables.range,"-")/>   <cfset variables.rangeLength = variables.max - variables.min + 1/>            <cfheader statuscode="206" statustext="Partial Content">   <cfheader name="Accept-Ranges" value="bytes">   <cfheader name="Content-Range" value="bytes #variables.range#/#getFileSize.size#">   <cfheader name="Content-Length" value="#variables.rangeLength#"> <cfelse>    <cfheader name="Content-Length" value="#getFileSize.size#"> </cfif> <!--- Open the file. ---> <cfheader name="Last-Modified" value="#variables.dateStr#"> <cfheader name="Content-disposition" value="attachment;filename=#origFileName#"> <cfcontent type="application/octet-stream" file="#decryptedDoc#">

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dave Watts
01/12/2012 09:44 AM

> I have come up with a solution but it is not working 100%.  It seems like the Content-Range header is not working.  I return the correct Content-Length, but it always starts at the beginning of the file.  See code below... > > ... > > <cfcontent type="application/octet-stream" file="#decryptedDoc#"> CF isn't going to know anything about your range headers. It's just going to serve the file. If you wanted to serve part of the file, you'd have to read it into memory and serve the slice that you want to serve. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsi

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Chad Baloga
01/12/2012 10:05 AM

> CF isn't going to know anything about your range headers. It's just > going to serve the file. If you wanted to serve part of the file, > you'd have to read it into memory and serve the slice that you want > to > serve. Using cffile read? Is 1 character considered to be a "byte"?

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Dave Watts
01/12/2012 10:09 AM

> Using cffile read? Is 1 character considered to be a "byte"? Usually, a character is one byte in size, but you can use the READBINARY action value instead, and use ToBase64 to serve it. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite.


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 20, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Designer, Developer and mobile workflow conference