From 165cab7a2952ff82155d44af1c34a80e293c65f5 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 17 Aug 2015 23:47:35 +0900 Subject: [PATCH] nghttpd: Support HEAD request --- src/HttpServer.cc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/HttpServer.cc b/src/HttpServer.cc index 01624d33..8ca4de00 100644 --- a/src/HttpServer.cc +++ b/src/HttpServer.cc @@ -1106,23 +1106,26 @@ void prepare_response(Stream *stream, Http2Handler *hd, return; } - if (last_mod_found && static_cast(buf.st_mtime) <= last_mod) { - close(file); - hd->submit_response("304", stream->stream_id, nullptr); - - return; - } - file_ent = sessions->cache_fd( path, FileEntry(path, buf.st_size, buf.st_mtime, file)); - } else if (last_mod_found && file_ent->mtime <= last_mod) { - sessions->release_fd(file_ent->path); + } + + stream->file_ent = file_ent; + + if (last_mod_found && file_ent->mtime <= last_mod) { hd->submit_response("304", stream->stream_id, nullptr); return; } - stream->file_ent = file_ent; + auto &method = http2::get_header(stream->hdidx, http2::HD__METHOD, + stream->headers)->value; + if (method == "HEAD") { + hd->submit_file_response("200", stream, file_ent->mtime, file_ent->length, + nullptr); + return; + } + stream->body_length = file_ent->length; nghttp2_data_provider data_prd;