|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
cfheader Content-Range
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.Chad Baloga 01/04/12 07:50 A > Does anyone know how to get Content-Range returned as a header response when the request has "Range: bytes= " in it?Dave Watts 01/04/12 10:26 A 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...Chad Baloga 01/12/12 06:33 A > 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...Dave Watts 01/12/12 09:44 A > CF isn't going to know anything about your range headers. It's justChad Baloga 01/12/12 10:05 A > Using cffile read? Is 1 character considered to be a "byte"?Dave Watts 01/12/12 10:09 A 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. > 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 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#"> > 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 > 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"? > 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.
|
May 20, 2013
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||