Skip to content

Commit

Permalink
Added HTTP header Expires: to support max-age for HTTP/1.0 connection…
Browse files Browse the repository at this point in the history
…s too

git-svn-id: svn://cherokee-project.com/cherokee/trunk@1008 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information
ADF committed Feb 5, 2008
1 parent e7545fd commit 147554c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
12 changes: 11 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@

2008-02-05 A.D.F <adefacc@tin.it>

* macros.h, connection.c:
- fixed mispelling, renamed MSECONS_TO_LINGER to MSECONDS_TO_LINGER.

* handler_file.c:
- added HTTP header "Expires: RFC1123 date" for HTTP/1.0 connections
in order to complete support for max-age cache control.

2008-02-04 A.D.F <adefacc@tin.it>

* mime.types.sample:
- add a few more comments about syntax of the file;
- added a few more comments about syntax of the file;
- included the content of mime.compression.types.sample
into mime.types.sample;
NOTE: workaround for Cherokee 0.6x.
Expand Down
2 changes: 1 addition & 1 deletion cherokee/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ cherokee_connection_shutdown_wr (cherokee_connection_t *conn)
/* Set the timeout for future linger read(s) leaving the
* non-blocking mode.
*/
conn->timeout = CONN_THREAD(conn)->bogo_now + (MSECONS_TO_LINGER / 1000) + 1;
conn->timeout = CONN_THREAD(conn)->bogo_now + (MSECONDS_TO_LINGER / 1000) + 1;

/* Shut down the socket for write, which will send a FIN to
* the peer. If shutdown fails then the socket is unusable.
Expand Down
17 changes: 17 additions & 0 deletions cherokee/handler_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,26 @@ cherokee_handler_file_add_headers (cherokee_handler_file_t *fhdl,

ret = cherokee_mime_entry_get_maxage (fhdl->mime, &maxage);
if (ret == ret_ok) {
/* Cache-Control, note that we add it in any case
* because it can be useful for client and / or transparent
* proxies (working in the middle with HTTP/1.1 connections) too.
*/
cherokee_buffer_add_str (buffer, "Cache-Control: max-age=");
cherokee_buffer_add_ulong10(buffer, (culong_t) maxage);
cherokee_buffer_add_str (buffer, CRLF);

if (conn->header.version < http_version_11) {
time_t exp_time = CONN_THREAD(conn)->bogo_now + (time_t)maxage;

/* Expire-Time for HTTP/1.0 connections.
*/
cherokee_gmtime (&exp_time, &modified_tm);
szlen = cherokee_dtm_gmttm2str(bufstr,
DTM_SIZE_GMTTM_STR, &modified_tm);
cherokee_buffer_add_str(buffer, "Expires: ");
cherokee_buffer_add (buffer, bufstr, szlen);
cherokee_buffer_add_str(buffer, CRLF);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion cherokee/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
#define TERMINAL_WIDTH 80
#define DEFAULT_TRAFFIC_UPDATE 10
#define CGI_TIMEOUT 65
#define MSECONS_TO_LINGER 2000
#define MSECONDS_TO_LINGER 2000
#define POST_SIZE_TO_DISK 32768
#define LOGGER_MIN_BUFSIZE 0
#define DEFAULT_LOGGER_MAX_BUFSIZE 32768
Expand Down

0 comments on commit 147554c

Please sign in to comment.