TS-1867: combo_handler crashes with non-200 responses combo_handler crashes when combining non-200 response from upstream.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/8650d81f Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/8650d81f Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/8650d81f Branch: refs/heads/sphinx-docs Commit: 8650d81f725af40bd2143485922cfa34a8eec33a Parents: c400c88 Author: Conan Wang <[email protected]> Authored: Fri May 3 12:47:20 2013 -0700 Committer: James Peach <[email protected]> Committed: Fri May 3 12:48:35 2013 -0700 ---------------------------------------------------------------------- CHANGES | 3 +++ plugins/experimental/esi/combo_handler.cc | 2 +- .../esi/fetcher/HttpDataFetcherImpl.cc | 2 +- .../experimental/esi/fetcher/HttpDataFetcherImpl.h | 10 ++++++---- 4 files changed, 11 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8650d81f/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 648df17..362fcd0 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache Traffic Server 3.3.3 + *) [TS-1867] The combo_handler plugin crashes when receiving non-200 responses. + Author: Conan Wang <[email protected]> + *) [TS-1838] Improve configure.ac to recognize compiler setup better. *) [TS-1865] Support DESTDIR in tsxs. http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8650d81f/plugins/experimental/esi/combo_handler.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/esi/combo_handler.cc b/plugins/experimental/esi/combo_handler.cc index 90b9290..89a8fd6 100644 --- a/plugins/experimental/esi/combo_handler.cc +++ b/plugins/experimental/esi/combo_handler.cc @@ -711,7 +711,7 @@ prepareResponse(InterceptData &int_data, ByteBlockList &body_blocks, string &res bool got_expires_time = false; for (StringList::iterator iter = int_data.creq.file_urls.begin(); iter != int_data.creq.file_urls.end(); ++iter) { - if (int_data.fetcher->getData(*iter, resp_data)) { + if (int_data.fetcher->getData(*iter, resp_data) && resp_data.status == TS_HTTP_STATUS_OK) { body_blocks.push_back(ByteBlock(resp_data.content, resp_data.content_len)); if (!got_content_type) { got_content_type = getContentType(resp_data.bufp, resp_data.hdr_loc, resp_header_fields); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8650d81f/plugins/experimental/esi/fetcher/HttpDataFetcherImpl.cc ---------------------------------------------------------------------- diff --git a/plugins/experimental/esi/fetcher/HttpDataFetcherImpl.cc b/plugins/experimental/esi/fetcher/HttpDataFetcherImpl.cc index 157257e..427437d 100644 --- a/plugins/experimental/esi/fetcher/HttpDataFetcherImpl.cc +++ b/plugins/experimental/esi/fetcher/HttpDataFetcherImpl.cc @@ -273,7 +273,7 @@ HttpDataFetcherImpl::getData(const string &url, ResponseData &resp_data) const return false; } - resp_data.set(req_data.body, req_data.body_len, req_data.bufp, req_data.hdr_loc); + resp_data.set(req_data.body, req_data.body_len, req_data.bufp, req_data.hdr_loc, req_data.resp_status); TSDebug(_debug_tag, "[%s] Found data for URL [%s] of size %d starting with [%.5s]", __FUNCTION__, url.data(), req_data.body_len, req_data.body); return true; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/8650d81f/plugins/experimental/esi/fetcher/HttpDataFetcherImpl.h ---------------------------------------------------------------------- diff --git a/plugins/experimental/esi/fetcher/HttpDataFetcherImpl.h b/plugins/experimental/esi/fetcher/HttpDataFetcherImpl.h index 8864d74..29dccaa 100644 --- a/plugins/experimental/esi/fetcher/HttpDataFetcherImpl.h +++ b/plugins/experimental/esi/fetcher/HttpDataFetcherImpl.h @@ -65,9 +65,10 @@ public: int content_len; TSMBuffer bufp; TSMLoc hdr_loc; - ResponseData() { set(0, 0, 0, 0); } - inline void set(const char *c, int clen, TSMBuffer b, TSMLoc loc); - void clear() { set(0, 0, 0, 0); } + TSHttpStatus status; + ResponseData() { set(0, 0, 0, 0, TS_HTTP_STATUS_NONE); } + inline void set(const char *c, int clen, TSMBuffer b, TSMLoc loc, TSHttpStatus s); + void clear() { set(0, 0, 0, 0, TS_HTTP_STATUS_NONE); } }; bool getData(const std::string &url, ResponseData &resp_data) const; @@ -136,11 +137,12 @@ private: }; inline void -HttpDataFetcherImpl::ResponseData::set(const char *c, int clen, TSMBuffer b, TSMLoc loc) { +HttpDataFetcherImpl::ResponseData::set(const char *c, int clen, TSMBuffer b, TSMLoc loc, TSHttpStatus s) { content = c; content_len = clen; bufp = b; hdr_loc = loc; + status = s; } #endif
