You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by br...@apache.org on 2015/07/23 06:09:26 UTC
[1/4] trafficserver git commit: TS-3779: Body Factory: support per
host error pages
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 <zi...@linkedin.com>
Authored: Mon Jul 20 22:28:32 2015 -0700
Committer: Zizhong Zhang <zi...@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
[2/4] trafficserver git commit: TS-3779: Body Factory: support per
host error pages: TESTS
Posted by br...@apache.org.
TS-3779: Body Factory: support per host error pages: TESTS
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/1ee3c26c
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/1ee3c26c
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/1ee3c26c
Branch: refs/heads/master
Commit: 1ee3c26c19c3952c6249e0ce57e57c444cd07064
Parents: 09beb11
Author: Zizhong Zhang <zi...@linkedin.com>
Authored: Mon Jul 20 22:34:44 2015 -0700
Committer: Zizhong Zhang <zi...@linkedin.com>
Committed: Mon Jul 20 22:34:44 2015 -0700
----------------------------------------------------------------------
ci/tsqa/tests/test_body_factory.py | 79 +++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1ee3c26c/ci/tsqa/tests/test_body_factory.py
----------------------------------------------------------------------
diff --git a/ci/tsqa/tests/test_body_factory.py b/ci/tsqa/tests/test_body_factory.py
new file mode 100644
index 0000000..fd8f8b5
--- /dev/null
+++ b/ci/tsqa/tests/test_body_factory.py
@@ -0,0 +1,79 @@
+'''
+Test body_factory
+'''
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+import requests
+import time
+import logging
+import SocketServer
+import random
+import tsqa.test_cases
+import helpers
+import json
+
+log = logging.getLogger(__name__)
+
+class TestDomainSpecificBodyFactory(helpers.EnvironmentCase):
+ '''
+ Tests for how body factory works with requests of different domains
+ '''
+ @classmethod
+ def setUpEnv(cls, env):
+ cls.configs['records.config']['CONFIG'].update({
+ 'proxy.config.body_factory.enable_customizations': 3, # enable domain specific body factory
+ })
+ cls.configs['remap.config'].add_line(
+ 'map / http://www.linkedin.com/ @action=deny'
+ )
+ cls.body_factory_dir = os.path.join(cls.environment.layout.prefix, cls.configs['records.config']['CONFIG']['proxy.config.body_factory.template_sets_dir'])
+ cls.domain_directory = ['www.linkedin.com', '127.0.0.1', 'www.foobar.net']
+ for directory_item in cls.domain_directory:
+ current_dir = os.path.join(cls.body_factory_dir, directory_item)
+ try:
+ os.mkdir(current_dir)
+ except:
+ pass
+ fname = os.path.join(current_dir, "access#denied")
+ with open(fname, "w") as f:
+ f.write(directory_item)
+ fname = os.path.join(current_dir, ".body_factory_info")
+ with open(fname, "w") as f:
+ pass
+
+ def test_domain_specific_body_factory(self):
+ times = 1000
+ no_dir_domain = 'www.nodir.com'
+ self.domain_directory.append(no_dir_domain)
+ self.assertEqual(4, len(self.domain_directory))
+ url = 'http://127.1.0.1:{0}'.format(self.configs['records.config']['CONFIG']['proxy.config.http.server_ports'])
+ for i in xrange(times):
+ domain = random.choice(self.domain_directory)
+ headers = {'Host' : domain}
+ r = requests.get(url, headers = headers)
+ domain_in_response = no_dir_domain
+ for domain_item in self.domain_directory:
+ if domain_item in r.text:
+ domain_in_response = domain_item
+ break
+ self.assertEqual(domain, domain_in_response)
+
+
+
+
[4/4] trafficserver git commit: Merge branch 'bodyFactory' of
https://github.com/zizhong/trafficserver
Posted by br...@apache.org.
Merge branch 'bodyFactory' of https://github.com/zizhong/trafficserver
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/f5e521e6
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/f5e521e6
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/f5e521e6
Branch: refs/heads/master
Commit: f5e521e630515c7d745e12bc5b71fa049a21f2a7
Parents: b2b0040 ee92ad2
Author: Brian Geffon <br...@apache.org>
Authored: Wed Jul 22 21:09:11 2015 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Wed Jul 22 21:09:11 2015 -0700
----------------------------------------------------------------------
ci/tsqa/tests/test_body_factory.py | 79 ++++++++++++++++++++
.../configuration/records.config.en.rst | 1 +
proxy/http/HttpBodyFactory.cc | 22 +++++-
proxy/http/HttpBodyFactory.h | 1 +
4 files changed, 102 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
[3/4] trafficserver git commit: TS-3779: Body Factory: support per
host error pages: DOCUMENTATION
Posted by br...@apache.org.
TS-3779: Body Factory: support per host error pages: DOCUMENTATION
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ee92ad2d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ee92ad2d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ee92ad2d
Branch: refs/heads/master
Commit: ee92ad2ddb90570a7f2f94bc7f11afed6904268a
Parents: 1ee3c26
Author: Zizhong Zhang <zi...@linkedin.com>
Authored: Mon Jul 20 22:37:31 2015 -0700
Committer: Zizhong Zhang <zi...@linkedin.com>
Committed: Mon Jul 20 22:37:31 2015 -0700
----------------------------------------------------------------------
doc/reference/configuration/records.config.en.rst | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ee92ad2d/doc/reference/configuration/records.config.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/configuration/records.config.en.rst b/doc/reference/configuration/records.config.en.rst
index 8ada5e1..0b0a150 100644
--- a/doc/reference/configuration/records.config.en.rst
+++ b/doc/reference/configuration/records.config.en.rst
@@ -1690,6 +1690,7 @@ Customizable User Response Pages
- ``1`` = enable customizable user response pages in the default directory only
- ``2`` = enable language-targeted user response pages
+ - ``3`` = enable host-targeted user response pages
.. ts:cv:: CONFIG proxy.config.body_factory.enable_logging INT 0