From d956619380ec37738f84f362a5c9b16d80c025a2 Mon Sep 17 00:00:00 2001 From: Jan Kneschke Date: Fri, 2 Sep 2005 10:45:45 +0000 Subject: [PATCH] make MacOS X happy when it domes to mod_cml and lua git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@676 152afb58-edef-0310-8abb-c4023f1b3aa9 --- configure.in | 2 +- src/http-header-glue.c | 88 ++++++++++++++++++++++++++++++++++++++++++ src/response.c | 88 ------------------------------------------ 3 files changed, 89 insertions(+), 89 deletions(-) diff --git a/configure.in b/configure.in index 7b28e15f..d63bfb1e 100644 --- a/configure.in +++ b/configure.in @@ -360,7 +360,7 @@ if test "$WITH_LUA" != "no"; then else AC_CHECK_LIB(lua, lua_open, [ AC_CHECK_HEADERS([lua.h],[ - LUA_LIB=-llua -llualib + LUA_LIB="-llua -llualib" AC_DEFINE([HAVE_LUA], [1], [liblua]) AC_DEFINE([HAVE_LUA_H], [1], [lua.h]) ]) diff --git a/src/http-header-glue.c b/src/http-header-glue.c index 3d1fc2d4..70ca909e 100644 --- a/src/http-header-glue.c +++ b/src/http-header-glue.c @@ -225,3 +225,91 @@ buffer * strftime_cache_get(server *srv, time_t last_mod) { } +int http_response_handle_cachable(server *srv, connection *con, buffer *mtime) { + /* + * 14.26 If-None-Match + * [...] + * If none of the entity tags match, then the server MAY perform the + * requested method as if the If-None-Match header field did not exist, + * but MUST also ignore any If-Modified-Since header field(s) in the + * request. That is, if no entity tags match, then the server MUST NOT + * return a 304 (Not Modified) response. + */ + + /* last-modified handling */ + if (con->request.http_if_none_match) { + if (etag_is_equal(con->physical.etag, con->request.http_if_none_match)) { + if (con->request.http_method == HTTP_METHOD_GET || + con->request.http_method == HTTP_METHOD_HEAD) { + + /* check if etag + last-modified */ + if (con->request.http_if_modified_since) { + + size_t used_len; + char *semicolon; + + if (NULL == (semicolon = strchr(con->request.http_if_modified_since, ';'))) { + used_len = strlen(con->request.http_if_modified_since); + } else { + used_len = semicolon - con->request.http_if_modified_since; + } + + if (0 == strncmp(con->request.http_if_modified_since, mtime->ptr, used_len)) { + con->http_status = 304; + return HANDLER_FINISHED; + } else { + char buf[sizeof("Sat, 23 Jul 2005 21:20:01 GMT")]; + + /* convert to timestamp */ + if (used_len < sizeof(buf) - 1) { + time_t t_header, t_file; + struct tm tm; + + strncpy(buf, con->request.http_if_modified_since, used_len); + buf[used_len] = '\0'; + + strptime(buf, "%a, %d %b %Y %H:%M:%S GMT", &tm); + t_header = mktime(&tm); + + strptime(mtime->ptr, "%a, %d %b %Y %H:%M:%S GMT", &tm); + t_file = mktime(&tm); + + if (t_file > t_header) { + con->http_status = 304; + return HANDLER_FINISHED; + } + } else { + log_error_write(srv, __FILE__, __LINE__, "ss", + con->request.http_if_modified_since, buf); + + con->http_status = 412; + return HANDLER_FINISHED; + } + } + } else { + con->http_status = 304; + return HANDLER_FINISHED; + } + } else { + con->http_status = 412; + return HANDLER_FINISHED; + } + } + } else if (con->request.http_if_modified_since) { + size_t used_len; + char *semicolon; + + if (NULL == (semicolon = strchr(con->request.http_if_modified_since, ';'))) { + used_len = strlen(con->request.http_if_modified_since); + } else { + used_len = semicolon - con->request.http_if_modified_since; + } + + if (0 == strncmp(con->request.http_if_modified_since, mtime->ptr, used_len)) { + con->http_status = 304; + return HANDLER_FINISHED; + } + } + + return HANDLER_GO_ON; +} diff --git a/src/response.c b/src/response.c index c39650ea..99c26ce9 100644 --- a/src/response.c +++ b/src/response.c @@ -563,91 +563,3 @@ handler_t http_response_prepare(server *srv, connection *con) { -int http_response_handle_cachable(server *srv, connection *con, buffer *mtime) { - /* - * 14.26 If-None-Match - * [...] - * If none of the entity tags match, then the server MAY perform the - * requested method as if the If-None-Match header field did not exist, - * but MUST also ignore any If-Modified-Since header field(s) in the - * request. That is, if no entity tags match, then the server MUST NOT - * return a 304 (Not Modified) response. - */ - - /* last-modified handling */ - if (con->request.http_if_none_match) { - if (etag_is_equal(con->physical.etag, con->request.http_if_none_match)) { - if (con->request.http_method == HTTP_METHOD_GET || - con->request.http_method == HTTP_METHOD_HEAD) { - - /* check if etag + last-modified */ - if (con->request.http_if_modified_since) { - - size_t used_len; - char *semicolon; - - if (NULL == (semicolon = strchr(con->request.http_if_modified_since, ';'))) { - used_len = strlen(con->request.http_if_modified_since); - } else { - used_len = semicolon - con->request.http_if_modified_since; - } - - if (0 == strncmp(con->request.http_if_modified_since, mtime->ptr, used_len)) { - con->http_status = 304; - return HANDLER_FINISHED; - } else { - char buf[sizeof("Sat, 23 Jul 2005 21:20:01 GMT")]; - - /* convert to timestamp */ - if (used_len < sizeof(buf) - 1) { - time_t t_header, t_file; - struct tm tm; - - strncpy(buf, con->request.http_if_modified_since, used_len); - buf[used_len] = '\0'; - - strptime(buf, "%a, %d %b %Y %H:%M:%S GMT", &tm); - t_header = mktime(&tm); - - strptime(mtime->ptr, "%a, %d %b %Y %H:%M:%S GMT", &tm); - t_file = mktime(&tm); - - if (t_file > t_header) { - con->http_status = 304; - return HANDLER_FINISHED; - } - } else { - log_error_write(srv, __FILE__, __LINE__, "ss", - con->request.http_if_modified_since, buf); - - con->http_status = 412; - return HANDLER_FINISHED; - } - } - } else { - con->http_status = 304; - return HANDLER_FINISHED; - } - } else { - con->http_status = 412; - return HANDLER_FINISHED; - } - } - } else if (con->request.http_if_modified_since) { - size_t used_len; - char *semicolon; - - if (NULL == (semicolon = strchr(con->request.http_if_modified_since, ';'))) { - used_len = strlen(con->request.http_if_modified_since); - } else { - used_len = semicolon - con->request.http_if_modified_since; - } - - if (0 == strncmp(con->request.http_if_modified_since, mtime->ptr, used_len)) { - con->http_status = 304; - return HANDLER_FINISHED; - } - } - - return HANDLER_GO_ON; -}