Repository: trafficserver Updated Branches: refs/heads/master b2b004066 -> f5e521e63
TS-3779: Body Factory: support per host error pages Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/09beb115 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/09beb115 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/09beb115 Branch: refs/heads/master Commit: 09beb115c52802bab2967bde2ac9c7cdc14fd68d Parents: bb6f9f3 Author: Zizhong Zhang <zizh...@linkedin.com> Authored: Mon Jul 20 22:28:32 2015 -0700 Committer: Zizhong Zhang <zizh...@linkedin.com> Committed: Mon Jul 20 22:28:32 2015 -0700 ---------------------------------------------------------------------- proxy/http/HttpBodyFactory.cc | 22 +++++++++++++++++++++- proxy/http/HttpBodyFactory.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/09beb115/proxy/http/HttpBodyFactory.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpBodyFactory.cc b/proxy/http/HttpBodyFactory.cc index 51a3e8f..89960b2 100644 --- a/proxy/http/HttpBodyFactory.cc +++ b/proxy/http/HttpBodyFactory.cc @@ -419,10 +419,13 @@ HttpBodyFactory::fabricate(StrList *acpt_language_list, StrList *acpt_charset_li Debug("body_factory", " customization disabled, returning NULL template"); return (NULL); } + // what set should we use (language target if enable_customizations == 2) if (enable_customizations == 2) set = determine_set_by_language(acpt_language_list, acpt_charset_list); - else + else if (enable_customizations == 3) { + set = determine_set_by_host(context); + } else set = "default"; if (set_return) @@ -446,6 +449,23 @@ HttpBodyFactory::fabricate(StrList *acpt_language_list, StrList *acpt_charset_li // LOCKING: must be called with lock taken const char * +HttpBodyFactory::determine_set_by_host(HttpTransact::State *context) { + const char *set; + RawHashTable_Value v; + int host_len = context->hh_info.host_len; + char host_buffer[host_len + 1]; + strncpy(host_buffer, context->hh_info.request_host, host_len); + host_buffer[host_len] = '\0'; + if (table_of_sets->getValue((RawHashTable_Key)host_buffer, &v)) { + set = table_of_sets->getKeyFromBinding(table_of_sets->getCurrentBinding((RawHashTable_Key)host_buffer)); + } else { + set = "default"; + } + return set; +} + +// LOCKING: must be called with lock taken +const char * HttpBodyFactory::determine_set_by_language(StrList *acpt_language_list, StrList *acpt_charset_list) { float Q_best; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/09beb115/proxy/http/HttpBodyFactory.h ---------------------------------------------------------------------- diff --git a/proxy/http/HttpBodyFactory.h b/proxy/http/HttpBodyFactory.h index 110b0df..f5c4086 100644 --- a/proxy/http/HttpBodyFactory.h +++ b/proxy/http/HttpBodyFactory.h @@ -187,6 +187,7 @@ private: const char **set_return = NULL); const char *determine_set_by_language(StrList *acpt_language_list, StrList *acpt_charset_list); + const char *determine_set_by_host(HttpTransact::State *context); HttpBodyTemplate *find_template(const char *set, const char *type, HttpBodySet **body_set_return); bool is_response_suppressed(HttpTransact::State *context); bool