fix calculation of 'Expires:' header, also handle HTTP HEAD requests

This commit is contained in:
Christian Grothoff 2017-09-26 13:56:33 +02:00
parent a8de810bf7
commit 472853442f
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 24 additions and 16 deletions

View File

@ -320,6 +320,9 @@ handle_mhd_request (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Handling request for URL '%s'\n", "Handling request for URL '%s'\n",
url); url);
if (0 == strcasecmp (method,
MHD_HTTP_METHOD_HEAD))
method = MHD_HTTP_METHOD_GET; /* treat HEAD as GET here, MHD will do the rest */
for (unsigned int i=0;NULL != handlers[i].url;i++) for (unsigned int i=0;NULL != handlers[i].url;i++)
{ {
rh = &handlers[i]; rh = &handlers[i];

View File

@ -1047,12 +1047,15 @@ setup_general_response_headers (const struct TEH_KS_StateHandle *key_state,
MHD_add_response_header (response, MHD_add_response_header (response,
MHD_HTTP_HEADER_LAST_MODIFIED, MHD_HTTP_HEADER_LAST_MODIFIED,
dat)); dat));
get_date_string (key_state->next_reload, if (0 != key_state->next_reload.abs_value_us)
dat); {
GNUNET_break (MHD_YES == get_date_string (key_state->next_reload,
MHD_add_response_header (response, dat);
MHD_HTTP_HEADER_EXPIRES, GNUNET_break (MHD_YES ==
dat)); MHD_add_response_header (response,
MHD_HTTP_HEADER_EXPIRES,
dat));
}
return GNUNET_OK; return GNUNET_OK;
} }
@ -1458,6 +1461,13 @@ make_fresh_key_state ()
off++; off++;
} }
/* Compute next automatic reload time */
key_state->next_reload =
GNUNET_TIME_absolute_min (GNUNET_TIME_absolute_ntoh (key_state->current_sign_key_issue.issue.expire),
key_state->min_dk_expire);
GNUNET_assert (0 != key_state->next_reload.abs_value_us);
/* Initialize `krd_array` */ /* Initialize `krd_array` */
key_state->krd_array_length = off; key_state->krd_array_length = off;
key_state->krd_array key_state->krd_array
@ -1487,6 +1497,7 @@ make_fresh_key_state ()
} }
last = d; last = d;
} }
/* Finally, build an `empty` response without denomination keys /* Finally, build an `empty` response without denomination keys
for requests past the last known denomination key start date */ for requests past the last known denomination key start date */
if ( (off + 1 < key_state->krd_array_length) || if ( (off + 1 < key_state->krd_array_length) ||
@ -1503,12 +1514,6 @@ make_fresh_key_state ()
return NULL; return NULL;
} }
/* Compute next automatic reload time */
key_state->next_reload =
GNUNET_TIME_absolute_min (GNUNET_TIME_absolute_ntoh (key_state->current_sign_key_issue.issue.expire),
key_state->min_dk_expire);
GNUNET_assert (0 != key_state->next_reload.abs_value_us);
/* Clean up intermediary state we don't need anymore and return /* Clean up intermediary state we don't need anymore and return
new key_state! */ new key_state! */
destroy_response_factory (&rfc); destroy_response_factory (&rfc);

View File

@ -89,10 +89,10 @@ TEH_MHD_handler_static_response (struct TEH_RequestHandler *rh,
*/ */
int int
TEH_MHD_handler_agpl_redirect (struct TEH_RequestHandler *rh, TEH_MHD_handler_agpl_redirect (struct TEH_RequestHandler *rh,
struct MHD_Connection *connection, struct MHD_Connection *connection,
void **connection_cls, void **connection_cls,
const char *upload_data, const char *upload_data,
size_t *upload_data_size) size_t *upload_data_size)
{ {
const char *agpl = const char *agpl =
"This server is licensed under the Affero GPL. You will now be redirected to the source code."; "This server is licensed under the Affero GPL. You will now be redirected to the source code.";