Glenn Strauss 8 months ago
parent 206fafa37d
commit d0494fc081
  1. 4
      src/http-header-glue.c
  2. 1
      src/http_kv.c
  3. 6
      src/http_kv.h
  4. 2
      src/mod_deflate.c
  5. 10
      src/mod_expire.c
  6. 2
      src/mod_staticfile.c
  7. 2
      src/response.c

@ -211,7 +211,7 @@ int http_response_handle_cachable(request_st * const r, const buffer *lmod, cons
/*(weak etag comparison must not be used for ranged requests)*/
int range_request = (0 != light_btst(r->rqst_htags, HTTP_HEADER_RANGE));
if (http_etag_matches(etag, vb->ptr, !range_request)) {
if (http_method_get_or_head(r->http_method)) {
if (http_method_get_head_query(r->http_method)) {
r->http_status = 304;
return HANDLER_FINISHED;
} else {
@ -220,7 +220,7 @@ int http_response_handle_cachable(request_st * const r, const buffer *lmod, cons
return HANDLER_FINISHED;
}
}
} else if (http_method_get_or_head(r->http_method)
} else if (http_method_get_head_query(r->http_method)
&& (vb = http_header_request_get(r, HTTP_HEADER_IF_MODIFIED_SINCE,
CONST_STR_LEN("If-Modified-Since")))
&& (lmod

@ -28,6 +28,7 @@ static const keyvalue http_versions[] = {
static const buffer http_methods[] = {
{ CONST_STR_LEN("GET")+1, 0 },
{ CONST_STR_LEN("HEAD")+1, 0 },
{ CONST_STR_LEN("QUERY")+1, 0 },
{ CONST_STR_LEN("POST")+1, 0 },
{ CONST_STR_LEN("PUT")+1, 0 },
{ CONST_STR_LEN("DELETE")+1, 0 },

@ -19,6 +19,7 @@ typedef enum {
HTTP_METHOD_UNSET = -1,
HTTP_METHOD_GET, /* [RFC2616], Section 9.3 */
HTTP_METHOD_HEAD, /* [RFC2616], Section 9.4 */
HTTP_METHOD_QUERY, /* [RFCxxxx], Section 2 */
HTTP_METHOD_POST, /* [RFC2616], Section 9.5 */
HTTP_METHOD_PUT, /* [RFC2616], Section 9.6 */
HTTP_METHOD_DELETE, /* [RFC2616], Section 9.7 */
@ -89,8 +90,9 @@ void http_status_append(buffer *b, int status);
__attribute_nonnull__()
void http_version_append(buffer *b, http_version_t version);
#define http_method_get_or_head(method) ((method) <= HTTP_METHOD_HEAD)
#define http_method_get_head_post(method) ((method) <= HTTP_METHOD_POST)
#define http_method_get_or_head(method) ((method) <= HTTP_METHOD_HEAD)
#define http_method_get_head_query(method) ((method) <= HTTP_METHOD_QUERY)
#define http_method_get_head_query_post(method) ((method) <= HTTP_METHOD_POST)
__attribute_nonnull__()
static inline void http_method_append (buffer * const b, const http_method_t method);

@ -1959,7 +1959,7 @@ REQUEST_FUNC(mod_deflate_handle_response_start) {
&& if_none_match->ptr[etaglen-1] == '-'
&& 0 == strncmp(if_none_match->ptr+etaglen, label, strlen(label))) {
if (http_method_get_or_head(r->http_method)) {
if (http_method_get_head_query(r->http_method)) {
/* modify ETag response header in-place to remove '"' and append '-label"' */
vb->ptr[etaglen-1] = '-'; /*(overwrite end '"')*/
buffer_append_string(vb, label);

@ -293,10 +293,12 @@ REQUEST_FUNC(mod_expire_handler) {
buffer *vb;
const data_string *ds;
/* Add caching headers only to http_status 200 OK or 206 Partial Content */
if (r->http_status != 200 && r->http_status != 206) return HANDLER_GO_ON;
/* Add caching headers only to GET or HEAD requests */
if (!http_method_get_or_head(r->http_method)) return HANDLER_GO_ON;
/* Add caching headers only to http_status
* 200 OK or 204 No Content or 206 Partial Content */
if (r->http_status != 200 && r->http_status != 204 && r->http_status != 206)
return HANDLER_GO_ON;
/* Add caching headers only to GET, HEAD, QUERY requests */
if (!http_method_get_head_query(r->http_method)) return HANDLER_GO_ON;
/* Add caching headers only if not already present */
vb = http_header_response_get(r, HTTP_HEADER_CACHE_CONTROL, CONST_STR_LEN("Cache-Control"));
if (NULL != vb) return HANDLER_GO_ON;

@ -134,7 +134,7 @@ mod_staticfile_process (request_st * const r, plugin_config * const pconf)
URIHANDLER_FUNC(mod_staticfile_subrequest) {
if (NULL != r->handler_module) return HANDLER_GO_ON;
if (!http_method_get_head_post(r->http_method)) return HANDLER_GO_ON;
if (!http_method_get_head_query_post(r->http_method)) return HANDLER_GO_ON;
/* r->physical.path is non-empty for handle_subrequest_start */
/*if (buffer_is_blank(&r->physical.path)) return HANDLER_GO_ON;*/

@ -546,7 +546,7 @@ http_response_prepare (request_st * const r)
/* 405 Method Not Allowed */
return http_status_set_error_close(r, 405);
/*return http_response_prepare_connect(r);*/
else if (!http_method_get_head_post(r->http_method))
else if (!http_method_get_head_query_post(r->http_method))
r->http_status = 501;
else
r->http_status = 403;

Loading…
Cancel
Save