Repository: trafficserver Updated Branches: refs/heads/master 5c37860c7 -> d26674750
[TS-3199]: Do not wait for body for HEAD method Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/d2667475 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/d2667475 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/d2667475 Branch: refs/heads/master Commit: d26674750e10c89029d752e86de4dc6ef5bf3588 Parents: 5c37860 Author: Sudheer Vinukonda <[email protected]> Authored: Sat Nov 15 00:26:16 2014 +0000 Committer: Sudheer Vinukonda <[email protected]> Committed: Sat Nov 15 00:26:16 2014 +0000 ---------------------------------------------------------------------- proxy/FetchSM.cc | 9 ++++++++- proxy/FetchSM.h | 4 ++-- proxy/spdy/SpdyClientSession.cc | 7 ++----- 3 files changed, 12 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d2667475/proxy/FetchSM.cc ---------------------------------------------------------------------- diff --git a/proxy/FetchSM.cc b/proxy/FetchSM.cc index 91d1111..ad7e655 100644 --- a/proxy/FetchSM.cc +++ b/proxy/FetchSM.cc @@ -105,6 +105,8 @@ FetchSM::has_body() if (!header_done) return false; + if (is_method_head) + return false; // // The following code comply with HTTP/1.1: // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4 @@ -550,12 +552,17 @@ FetchSM::ext_init(Continuation *cont, const char *method, memset(&callback_options, 0, sizeof(callback_options)); memset(&callback_events, 0, sizeof(callback_events)); - req_buffer->write(method, strlen(method)); + int method_len = strlen(method); + req_buffer->write(method, method_len); req_buffer->write(" ", 1); req_buffer->write(url, strlen(url)); req_buffer->write(" ", 1); req_buffer->write(version, strlen(version)); req_buffer->write("\r\n", 2); + + if ((method_len == strlen("HEAD")) && !memcmp(method, "HEAD", method_len)) { + is_method_head = true; + } } void http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d2667475/proxy/FetchSM.h ---------------------------------------------------------------------- diff --git a/proxy/FetchSM.h b/proxy/FetchSM.h index 1200fe5..1725f37 100644 --- a/proxy/FetchSM.h +++ b/proxy/FetchSM.h @@ -48,7 +48,7 @@ public: is_internal_request = true; recursion = 0; req_finished = 0; - resp_finished = 0; + is_method_head = 0; header_done = 0; user_data = NULL; has_sent_header = false; @@ -165,7 +165,7 @@ private: TSFetchWakeUpOptions callback_options; bool req_finished; bool header_done; - bool resp_finished; + bool is_method_head; bool is_internal_request; IpEndpoint _addr; int resp_is_chunked; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d2667475/proxy/spdy/SpdyClientSession.cc ---------------------------------------------------------------------- diff --git a/proxy/spdy/SpdyClientSession.cc b/proxy/spdy/SpdyClientSession.cc index 8c56340..e003d0e 100644 --- a/proxy/spdy/SpdyClientSession.cc +++ b/proxy/spdy/SpdyClientSession.cc @@ -339,18 +339,15 @@ spdy_process_fetch(TSEvent event, SpdyClientSession *sm, void *edata) if (req->fetch_body_completed) ret = 0; // Ignore fetch errors after FETCH BODY DONE else { - Error("spdy_process_fetch fetch error, fetch_sm %p, ret %d for sm_id %" PRId64 ", stream_id %u, req time %" PRId64 ", url %s", req->fetch_sm, ret, sm->sm_id, req->stream_id, req->start_time, req->url.c_str()); + Debug("spdy_error", "spdy_process_fetch fetch error, fetch_sm %p, ret %d for sm_id %" PRId64 ", stream_id %u, req time %" PRId64 ", url %s", req->fetch_sm, ret, sm->sm_id, req->stream_id, req->start_time, req->url.c_str()); req->fetch_sm = NULL; } break; } if (ret) { - Error("spdy_process_fetch sending STATUS_500, fetch_sm %p, ret %d for sm_id %" PRId64 ", stream_id %u, req time %" PRId64 ", url %s", req->fetch_sm, ret, sm->sm_id, req->stream_id, req->start_time, req->url.c_str()); + Debug("spdy_error", "spdy_process_fetch sending STATUS_500, fetch_sm %p, ret %d for sm_id %" PRId64 ", stream_id %u, req time %" PRId64 ", url %s", req->fetch_sm, ret, sm->sm_id, req->stream_id, req->start_time, req->url.c_str()); spdy_prepare_status_response_and_clean_request(sm, req->stream_id, STATUS_500); - // It is better to send back a 500 response on the stream and have the client connection remain open. However, we - // have seen a core around this. We have a local patch to close the client connection (return -1) this is related - // to TS-2883. TS-2883 still needs to be fixed. } return 0;
