ngx_table_elt_t *h, ngx_uint_t offset);
static ngx_int_t ngx_http_process_connection(ngx_http_request_t *r,
ngx_table_elt_t *h, ngx_uint_t offset);
+static ngx_int_t ngx_http_process_proxy_connection(ngx_http_request_t *r,
+ ngx_table_elt_t *h, ngx_uint_t offset);
static ngx_int_t ngx_http_process_user_agent(ngx_http_request_t *r,
ngx_table_elt_t *h, ngx_uint_t offset);
{ ngx_string("Connection"), offsetof(ngx_http_headers_in_t, connection),
ngx_http_process_connection },
+ { ngx_string("Proxy-Connection"), 0,
+ ngx_http_process_proxy_connection },
+
{ ngx_string("If-Modified-Since"),
offsetof(ngx_http_headers_in_t, if_modified_since),
ngx_http_process_unique_header_line },
}
+static ngx_int_t
+ngx_http_process_proxy_connection(ngx_http_request_t *r, ngx_table_elt_t *h,
+ ngx_uint_t offset)
+{
+ if (r->http_version >= NGX_HTTP_VERSION_20) {
+ ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
+ "client sent \"Proxy-Connection\" header");
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ return NGX_ERROR;
+ }
+
+ return NGX_OK;
+}
+
+
static ngx_int_t
ngx_http_process_user_agent(ngx_http_request_t *r, ngx_table_elt_t *h,
ngx_uint_t offset)
r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE;
+ if (r->headers_in.connection) {
+ ngx_log_error(NGX_LOG_INFO, fc->log, 0,
+ "client sent \"Connection\" header");
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ goto failed;
+ }
+
+ if (r->headers_in.keep_alive) {
+ ngx_log_error(NGX_LOG_INFO, fc->log, 0,
+ "client sent \"Keep-Alive\" header");
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ goto failed;
+ }
+
+ if (r->headers_in.transfer_encoding) {
+ ngx_log_error(NGX_LOG_INFO, fc->log, 0,
+ "client sent \"Transfer-Encoding\" header");
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ goto failed;
+ }
+
+ if (r->headers_in.upgrade) {
+ ngx_log_error(NGX_LOG_INFO, fc->log, 0,
+ "client sent \"Upgrade\" header");
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ goto failed;
+ }
+
+ if (r->headers_in.te
+ && (r->headers_in.te->value.len != 8
+ || ngx_strncasecmp(r->headers_in.te->value.data,
+ (u_char *) "trailers", 8) != 0))
+ {
+ ngx_log_error(NGX_LOG_INFO, fc->log, 0,
+ "client sent invalid \"TE\" header");
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ goto failed;
+ }
+
if (r->headers_in.server.len == 0) {
ngx_log_error(NGX_LOG_INFO, fc->log, 0,
"client sent neither \":authority\" nor \"Host\" header");
c = r->connection;
+ if (r->headers_in.connection) {
+ ngx_log_error(NGX_LOG_INFO, c->log, 0,
+ "client sent \"Connection\" header");
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ return NGX_ERROR;
+ }
+
+ if (r->headers_in.keep_alive) {
+ ngx_log_error(NGX_LOG_INFO, c->log, 0,
+ "client sent \"Keep-Alive\" header");
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ return NGX_ERROR;
+ }
+
+ if (r->headers_in.transfer_encoding) {
+ ngx_log_error(NGX_LOG_INFO, c->log, 0,
+ "client sent \"Transfer-Encoding\" header");
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ return NGX_ERROR;
+ }
+
+ if (r->headers_in.upgrade) {
+ ngx_log_error(NGX_LOG_INFO, c->log, 0,
+ "client sent \"Upgrade\" header");
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ return NGX_ERROR;
+ }
+
+ if (r->headers_in.te
+ && (r->headers_in.te->value.len != 8
+ || ngx_strncasecmp(r->headers_in.te->value.data,
+ (u_char *) "trailers", 8) != 0))
+ {
+ ngx_log_error(NGX_LOG_INFO, c->log, 0,
+ "client sent invalid \"TE\" header");
+ ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST);
+ return NGX_ERROR;
+ }
+
if (ngx_http_v3_init_pseudo_headers(r) != NGX_OK) {
return NGX_ERROR;
}