[core] feature flag to allow Range w/ HTTP/1.0

server.feature-flags += ( "http10.range" => "enable" )

The Range request header is HTTP/1.1, not HTTP/1.0.

Intermediate HTTP/1.0 proxies might mishandle or incorrectly cache
responses to HTTP/1.1 Range requests, so the default in lighttpd is
to ignore Range requests sent with HTTP/1.0.

This feature flag changes the default if an admin desires to support
dumb HTTP/1.0 clients that might (incorrectly) send Range requests
with HTTP/1.0.  Those client really ought to grow HTTP/1.1 support:
add support to receive HTTP/1.1 Transfer-Encoding: chunked responses,
and then those client may safely send HTTP/1.1 Range requests
(and in many cases, also Connection: close).
master
Glenn Strauss 10 months ago
parent 422d0355f5
commit 25f83b84b6
  1. 9
      src/http_range.c
  2. 3
      src/http_range.h
  3. 3
      src/server.c

@ -27,6 +27,14 @@
* interoperability. */
/* default: ignore Range with HTTP/1.0 requests */
static int http_range_allow_http10;
void http_range_config_allow_http10 (int flag)
{
http_range_allow_http10 = flag;
}
__attribute_noinline__
static int
http_range_coalesce (off_t * const restrict ranges, int n)
@ -347,6 +355,7 @@ http_range_rfc7233 (request_st * const r)
return http_status;
/* no "Range" in HTTP/1.0 */
if (r->http_version < HTTP_VERSION_1_1)
if (!http_range_allow_http10)
return http_status;
/* do not attempt to handle range if Transfer-Encoding already applied.
* skip Range processing if Content-Encoding has already been applied,

@ -11,6 +11,9 @@
#include "base_decls.h"
__attribute_cold__
void http_range_config_allow_http10 (int flag);
int http_range_rfc7233 (request_st *r);

@ -7,6 +7,7 @@
#include "rand.h"
#include "chunk.h"
#include "h2.h" /* h2_send_1xx() */
#include "http_range.h" /* http_range_config_allow_http10() */
#include "fdevent.h"
#include "fdlog.h"
#include "connections.h"
@ -1265,6 +1266,8 @@ static int server_main_setup (server * const srv, int argc, char **argv) {
if (!config_feature_bool(srv, "server.h1-discard-backend-1xx", 0))
http_response_send_1xx_cb_set(connection_send_1xx, HTTP_VERSION_1_1);
http_range_config_allow_http10(config_feature_bool(srv, "http10.range", 0));
if (0 != config_set_defaults(srv)) {
log_error(srv->errh, __FILE__, __LINE__,
"setting default values failed");

Loading…
Cancel
Save