Repository: trafficserver Updated Branches: refs/heads/master fa655be29 -> f3d8ee782
TS-2929: SPDY should allow arbitrary methods Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/b89ec596 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/b89ec596 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/b89ec596 Branch: refs/heads/master Commit: b89ec5963174788e3ed69d6540565fb39e64ac1a Parents: fa655be Author: Brian Geffon <bri...@apache.org> Authored: Tue Jul 8 14:06:35 2014 -0700 Committer: Brian Geffon <bri...@apache.org> Committed: Tue Jul 8 14:06:35 2014 -0700 ---------------------------------------------------------------------- proxy/FetchSM.cc | 28 ++++------------------------ proxy/FetchSM.h | 4 +--- proxy/InkAPI.cc | 2 +- proxy/api/ts/experimental.h | 17 +---------------- proxy/spdy/SpdyCallbacks.cc | 28 +++------------------------- 5 files changed, 10 insertions(+), 69 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b89ec596/proxy/FetchSM.cc ---------------------------------------------------------------------- diff --git a/proxy/FetchSM.cc b/proxy/FetchSM.cc index 0372e9c..56ab827 100644 --- a/proxy/FetchSM.cc +++ b/proxy/FetchSM.cc @@ -27,20 +27,6 @@ #include "HTTP.h" #include "PluginVC.h" -static const char *http_method[] = { - "NONE", - "GET", - "POST", - "CONNECT", - "DELETE", - "HEAD", - "PURGE", - "PUT", - "OPTIONS", - "TRACE", - "LAST", -}; - #define DEBUG_TAG "FetchSM" #define FETCH_LOCK_RETRY_TIME HRTIME_MSECONDS(10) @@ -124,9 +110,6 @@ FetchSM::has_body() // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.4 // - if (req_method == TS_FETCH_METHOD_HEAD) - return false; - hdr = &client_response_hdr; status_code = hdr->status_get(); @@ -486,7 +469,7 @@ FetchSM::fetch_handler(int event, void *edata) } void -FetchSM::ext_init(Continuation *cont, TSFetchMethod method, +FetchSM::ext_init(Continuation *cont, const char *method, const char *url, const char *version, const sockaddr *client_addr, int flags) { @@ -517,8 +500,7 @@ FetchSM::ext_init(Continuation *cont, TSFetchMethod method, memset(&callback_options, 0, sizeof(callback_options)); memset(&callback_events, 0, sizeof(callback_events)); - req_method = method; - req_buffer->write(http_method[method], strlen(http_method[method])); + req_buffer->write(method, strlen(method)); req_buffer->write(" ", 1); req_buffer->write(url, strlen(url)); req_buffer->write(" ", 1); @@ -551,9 +533,7 @@ FetchSM::ext_lanuch() void FetchSM::ext_write_data(const void *data, size_t len) { - bool writeReady = (header_done || - (req_method == TS_FETCH_METHOD_POST) || - (req_method == TS_FETCH_METHOD_PUT)); + bool writeReady = header_done; if (writeReady && (fetch_flags & TS_FETCH_FLAGS_NEWLOCK)) { MUTEX_TAKE_LOCK(mutex, this_ethread()); @@ -566,7 +546,7 @@ FetchSM::ext_write_data(const void *data, size_t len) // be initialized. // if (writeReady) { - Debug(DEBUG_TAG, "[%s] re-enabling write_vio, header_done %u, req_method %u", __FUNCTION__, header_done, req_method); + Debug(DEBUG_TAG, "[%s] re-enabling write_vio, header_done %u", __FUNCTION__, header_done); write_vio->reenable(); fetch_handler(TS_EVENT_VCONN_WRITE_READY, write_vio); } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b89ec596/proxy/FetchSM.h ---------------------------------------------------------------------- diff --git a/proxy/FetchSM.h b/proxy/FetchSM.h index 0eb0922..24a79af 100644 --- a/proxy/FetchSM.h +++ b/proxy/FetchSM.h @@ -52,7 +52,6 @@ public: header_done = 0; user_data = NULL; has_sent_header = false; - req_method = TS_FETCH_METHOD_NONE; req_content_length = 0; resp_is_chunked = -1; resp_content_length = -1; @@ -110,7 +109,7 @@ public: // // *flags* can be bitwise OR of several TSFetchFlags // - void ext_init(Continuation *cont, TSFetchMethod method, + void ext_init(Continuation *cont, const char *method, const char *url, const char *version, const sockaddr *client_addr, int flags); void ext_add_header(const char *name, int name_len, @@ -169,7 +168,6 @@ private: int fetch_flags; void *user_data; bool has_sent_header; - TSFetchMethod req_method; int64_t req_content_length; int64_t resp_content_length; int64_t resp_recived_body_len; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b89ec596/proxy/InkAPI.cc ---------------------------------------------------------------------- diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc index 23d17cb..7b2d6aa 100644 --- a/proxy/InkAPI.cc +++ b/proxy/InkAPI.cc @@ -7281,7 +7281,7 @@ TSFetchUrl(const char* headers, int request_len, sockaddr const* ip , TSCont con } TSFetchSM -TSFetchCreate(TSCont contp, TSFetchMethod method, +TSFetchCreate(TSCont contp, const char *method, const char *url, const char *version, struct sockaddr const* client_addr, int flags) { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b89ec596/proxy/api/ts/experimental.h ---------------------------------------------------------------------- diff --git a/proxy/api/ts/experimental.h b/proxy/api/ts/experimental.h index ac4cd8e..f82ff17 100644 --- a/proxy/api/ts/experimental.h +++ b/proxy/api/ts/experimental.h @@ -37,21 +37,6 @@ extern "C" { #endif /* __cplusplus */ - /* For Extended FetchSM APIs */ - typedef enum { - TS_FETCH_METHOD_NONE, - TS_FETCH_METHOD_GET, - TS_FETCH_METHOD_POST, - TS_FETCH_METHOD_CONNECT, - TS_FETCH_METHOD_DELETE, - TS_FETCH_METHOD_HEAD, - TS_FETCH_METHOD_PURGE, - TS_FETCH_METHOD_PUT, - TS_FETCH_METHOD_OPTIONS, - TS_FETCH_METHOD_TRACE, - TS_FETCH_METHOD_LAST - } TSFetchMethod; - typedef enum { TS_FETCH_EVENT_EXT_HEAD_READY = -1, @@ -651,7 +636,7 @@ extern "C" * * return TSFetchSM which should be destroyed by TSFetchDestroy(). */ - tsapi TSFetchSM TSFetchCreate(TSCont contp, TSFetchMethod method, + tsapi TSFetchSM TSFetchCreate(TSCont contp, const char *method, const char *url, const char *version, struct sockaddr const* client_addr, int flags); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/b89ec596/proxy/spdy/SpdyCallbacks.cc ---------------------------------------------------------------------- diff --git a/proxy/spdy/SpdyCallbacks.cc b/proxy/spdy/SpdyCallbacks.cc index 830c336..2023e0c 100644 --- a/proxy/spdy/SpdyCallbacks.cc +++ b/proxy/spdy/SpdyCallbacks.cc @@ -165,7 +165,7 @@ spdy_show_ctl_frame(const char *head_str, spdylay_session * /*session*/, spdylay } static int -spdy_fetcher_launch(SpdyRequest *req, TSFetchMethod method) +spdy_fetcher_launch(SpdyRequest *req) { string url; int fetch_flags; @@ -186,7 +186,7 @@ spdy_fetcher_launch(SpdyRequest *req, TSFetchMethod method) // TS-2906: FetchSM sets requests are internal requests, we need to not do that for SPDY streams. fetch_flags |= TS_FETCH_FLAGS_NOT_INTERNAL_REQUEST; - req->fetch_sm = TSFetchCreate((TSCont)sm, method, + req->fetch_sm = TSFetchCreate((TSCont)sm, req->method.c_str(), url.c_str(), req->version.c_str(), client_addr, fetch_flags); TSFetchUserDataSet(req->fetch_sm, req); @@ -293,29 +293,7 @@ spdy_process_syn_stream_frame(SpdyClientSession *sm, SpdyRequest *req) return; } - if (req->method == "GET") - spdy_fetcher_launch(req, TS_FETCH_METHOD_GET); - else if (req->method == "POST") - spdy_fetcher_launch(req, TS_FETCH_METHOD_POST); - else if (req->method == "PURGE") - spdy_fetcher_launch(req, TS_FETCH_METHOD_PURGE); - else if (req->method == "PUT") - spdy_fetcher_launch(req, TS_FETCH_METHOD_PUT); - else if (req->method == "HEAD") - spdy_fetcher_launch(req, TS_FETCH_METHOD_HEAD); - else if (req->method == "CONNECT") - spdy_fetcher_launch(req, TS_FETCH_METHOD_CONNECT); - else if (req->method == "DELETE") - spdy_fetcher_launch(req, TS_FETCH_METHOD_DELETE); - else if (req->method == "OPTIONS") - spdy_fetcher_launch(req, TS_FETCH_METHOD_OPTIONS); - else if (req->method == "TRACE") - spdy_fetcher_launch(req, TS_FETCH_METHOD_TRACE); - else if (req->method == "LAST") - spdy_fetcher_launch(req, TS_FETCH_METHOD_LAST); - else - spdy_prepare_status_response(sm, req->stream_id, STATUS_405); - + spdy_fetcher_launch(req); } void