Feature #2005

[PATCH] X-Sendfile-Range header support

Added by shellsage almost 5 years ago. Updated almost 5 years ago.

Status:WontfixStart date:2009-06-11
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:mod_fastcgi
Target version:-
Missing in 1.5.x:

Description

I've implemented an X-Sendfile-Range header to be used in conjunction with the X-Sendfile/X-LIGHTTPD-send-file headers that allows for specifying the range of bytes to serve from the file specified by the X-Sendfile header. This header is extremely useful. As one example, it makes pseudo-streaming and FLV from within a FastCGI application trivial, without having to jump through hoops with mod_magnet (as there is no response headers magnet yet in 1.4,) or upgrade to 1.5. This is very important, in my opinion, due to the conflicts with luasocket function names in lighttpd, disallowing the use of something like LUA's memcache module to pass information between the FastCGI app and mod_magnet.

My implementation requires the following header field definition:

X-Sendfile-Range: x y

Where, in this case, x is the first byte to serve (zero-based,) and y is the final byte to serve + 1.

Example:

X-Sendfile-Range: 5 7000

If the X-Sendfile-Range header is absent, functionality is identical in that the entire file is served by default. If it is present, it is parsed and its values are applied to the http_chunk_append_file function. The dynamically defined Content-Length header is also updated with the appropriate Content-Length based on the range given. Finally, the X-Sendfile-Range header is removed after being processed, so that it never makes it to the client.

I've tested this very much locally, and hope to have the attached patch pushed in an upcoming 1.4.x release. The attached patch is against r2522 of the lighttpd-1.4.x branch. Please let me know if you've any questions or concerns. Thanks!

x-sendfile-range.patch Magnifier - r2522 patch to add X-Sendfile-Range header support to 1.4.x. (2.52 KB) shellsage, 2009-06-11 06:07


Related issues

Related to Feature #2008: [PATCH] X-Sendfile-Extended header support Fixed 2009-06-15

Associated revisions

Revision 2531
Added by stbuehler almost 5 years ago

Add X-Sendfile-Range feature (fixes #2005)

Revision 2542
Added by stbuehler almost 5 years ago

Remove X-Sendfile-Range feature; it will be replaced with something more powerful (#2005, #2008)

History

#1 Updated by stbuehler almost 5 years ago

  • Target version changed from 1.4.x to 1.4.23

#2 Updated by stbuehler almost 5 years ago

  • Status changed from New to Fixed
  • % Done changed from 80 to 100

Applied in changeset r2531.

#3 Updated by stbuehler almost 5 years ago

  • Status changed from Fixed to Wontfix
  • Target version deleted (1.4.23)

This feature was removed, and we will try #2008 instead, so we don't have different methods for the same feature.

Also available in: Atom