Commit 8e03e830 authored by Łukasz Nowak's avatar Łukasz Nowak

caddy-frontend: Avoid needless double slashing for type:zope

For case if path (for zope) is provided from
/VirtualHostBase/https//example.com:443/zope_path/VirtualHostRoot/url_path
to
/VirtualHostBase/https/example.com:443/zope_path/VirtualHostRoot/url_path

If path (for zope) is not provided from

/VirtualHostBase/http//example.com:443//VirtualHostRoot/url_path
to
/VirtualHostBase/http/example.com:443/VirtualHostRoot/url_path
parent b78ae2ea
Pipeline #17519 passed with stage
...@@ -46,7 +46,7 @@ md5sum = 88af61e7abbf30dc99a1a2526161128d ...@@ -46,7 +46,7 @@ md5sum = 88af61e7abbf30dc99a1a2526161128d
[template-default-slave-virtualhost] [template-default-slave-virtualhost]
_update_hash_filename_ = templates/default-virtualhost.conf.in _update_hash_filename_ = templates/default-virtualhost.conf.in
md5sum = 13cd08d630cc51666a9f7e469fb6ea52 md5sum = 37475d79f28c5f126bc1947fdb938fdb
[template-backend-haproxy-configuration] [template-backend-haproxy-configuration]
_update_hash_filename_ = templates/backend-haproxy.cfg.in _update_hash_filename_ = templates/backend-haproxy.cfg.in
......
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
{%- if slave_parameter['prefer-gzip-encoding-to-backend'] %} {%- if slave_parameter['prefer-gzip-encoding-to-backend'] %}
{%- do proxy_append_list.append(('prefer-gzip', 'Proxy which always overrides Accept-Encoding to gzip if such is found')) %} {%- do proxy_append_list.append(('prefer-gzip', 'Proxy which always overrides Accept-Encoding to gzip if such is found')) %}
{%- endif %} {#- if slave_parameter['prefer-gzip-encoding-to-backend'] #} {%- endif %} {#- if slave_parameter['prefer-gzip-encoding-to-backend'] #}
{%- if slave_parameter['path'].strip().strip('/') %}
{%- set zope_path = slave_parameter['path'].strip().strip('/') ~ '/' %}
{%- else %}
{%- set zope_path = '' %}
{%- endif %}
{%- set http_host_list = [] %} {%- set http_host_list = [] %}
{%- set https_host_list = [] %} {%- set https_host_list = [] %}
{%- for host in slave_parameter['host_list'] %} {%- for host in slave_parameter['host_list'] %}
...@@ -129,27 +134,27 @@ ...@@ -129,27 +134,27 @@
regexp (.*) regexp (.*)
if {>Accept-Encoding} match "(^gzip,.*|.*, gzip,.*|.*, gzip$|^gzip$)" if {>Accept-Encoding} match "(^gzip,.*|.*, gzip,.*|.*, gzip$|^gzip$)"
{%- if tls %} {%- if tls %}
to /prefer-gzip/VirtualHostBase/{scheme}%2F%2F{hostonly}:{{ slave_parameter['virtualhostroot-https-port'] }}%2F{{ slave_parameter['path'] }}%2FVirtualHostRoot/{1} to /prefer-gzip/VirtualHostBase/{scheme}%2F{hostonly}:{{ slave_parameter['virtualhostroot-https-port'] }}%2F{{ zope_path }}VirtualHostRoot/{1}
{%- else %} {%- else %}
to /prefer-gzip/VirtualHostBase/{scheme}%2F%2F{hostonly}:{{ slave_parameter['virtualhostroot-http-port'] }}%2F{{ slave_parameter['path'] }}%2FVirtualHostRoot/{1} to /prefer-gzip/VirtualHostBase/{scheme}%2F{hostonly}:{{ slave_parameter['virtualhostroot-http-port'] }}%2F{{ zope_path }}VirtualHostRoot/{1}
{%- endif %} {%- endif %}
} }
rewrite { rewrite {
regexp (.*) regexp (.*)
if {>Accept-Encoding} not_match "(^gzip,.*|.*, gzip,.*|.*, gzip$|^gzip$)" if {>Accept-Encoding} not_match "(^gzip,.*|.*, gzip,.*|.*, gzip$|^gzip$)"
{%- if tls %} {%- if tls %}
to /VirtualHostBase/{scheme}%2F%2F{hostonly}:{{ slave_parameter['virtualhostroot-https-port'] }}%2F{{ slave_parameter['path'] }}%2FVirtualHostRoot/{1} to /VirtualHostBase/{scheme}%2F{hostonly}:{{ slave_parameter['virtualhostroot-https-port'] }}%2F{{ zope_path }}VirtualHostRoot/{1}
{%- else %} {%- else %}
to /VirtualHostBase/{scheme}%2F%2F{hostonly}:{{ slave_parameter['virtualhostroot-http-port'] }}%2F{{ slave_parameter['path'] }}%2FVirtualHostRoot/{1} to /VirtualHostBase/{scheme}%2F{hostonly}:{{ slave_parameter['virtualhostroot-http-port'] }}%2F{{ zope_path }}VirtualHostRoot/{1}
{%- endif %} {%- endif %}
} }
{%- else %} {%- else %}
rewrite { rewrite {
regexp (.*) regexp (.*)
{%- if tls %} {%- if tls %}
to /VirtualHostBase/{scheme}%2F%2F{hostonly}:{{ slave_parameter['virtualhostroot-https-port'] }}%2F{{ slave_parameter['path'] }}%2FVirtualHostRoot/{1} to /VirtualHostBase/{scheme}%2F{hostonly}:{{ slave_parameter['virtualhostroot-https-port'] }}%2F{{ zope_path }}VirtualHostRoot/{1}
{%- else %} {%- else %}
to /VirtualHostBase/{scheme}%2F%2F{hostonly}:{{ slave_parameter['virtualhostroot-http-port'] }}%2F{{ slave_parameter['path'] }}%2FVirtualHostRoot/{1} to /VirtualHostBase/{scheme}%2F{hostonly}:{{ slave_parameter['virtualhostroot-http-port'] }}%2F{{ zope_path }}VirtualHostRoot/{1}
{%- endif %} {%- endif %}
} {# rewrite #} } {# rewrite #}
{%- endif %} {#- if slave_parameter['prefer-gzip-encoding-to-backend'] #} {%- endif %} {#- if slave_parameter['prefer-gzip-encoding-to-backend'] #}
......
...@@ -2231,7 +2231,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2231,7 +2231,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
result, result,
'Path', 'Path',
'/VirtualHostBase/' '/VirtualHostBase/'
'https//typezopepath.example.com:443/path/to/some/resource' 'https/typezopepath.example.com:443/path/to/some/resource'
'/VirtualHostRoot/' '/VirtualHostRoot/'
'test-path/deeper' 'test-path/deeper'
) )
...@@ -2793,7 +2793,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2793,7 +2793,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.assertEqualResultJson( self.assertEqualResultJson(
result, result,
'Path', 'Path',
'/VirtualHostBase/https//typezope.example.com:443/' '/VirtualHostBase/https/typezope.example.com:443'
'/VirtualHostRoot/test-path/deeper' '/VirtualHostRoot/test-path/deeper'
) )
...@@ -2833,8 +2833,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2833,8 +2833,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.assertEqualResultJson( self.assertEqualResultJson(
result, result,
'Path', 'Path',
'/VirtualHostBase/https//' '/VirtualHostBase/https/'
'typezopeprefergzipencodingtobackendhttpsonly.example.com:443/' 'typezopeprefergzipencodingtobackendhttpsonly.example.com:443'
'/VirtualHostRoot/test-path/deeper' '/VirtualHostRoot/test-path/deeper'
) )
...@@ -2845,8 +2845,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2845,8 +2845,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.assertEqualResultJson( self.assertEqualResultJson(
result, result,
'Path', 'Path',
'/VirtualHostBase/http//' '/VirtualHostBase/http/'
'typezopeprefergzipencodingtobackendhttpsonly.example.com:80/' 'typezopeprefergzipencodingtobackendhttpsonly.example.com:80'
'/VirtualHostRoot/test-path/deeper' '/VirtualHostRoot/test-path/deeper'
) )
...@@ -2868,8 +2868,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2868,8 +2868,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.assertEqualResultJson( self.assertEqualResultJson(
result, result,
'Path', 'Path',
'/VirtualHostBase/https//' '/VirtualHostBase/https/'
'typezopeprefergzipencodingtobackendhttpsonly.example.com:443/' 'typezopeprefergzipencodingtobackendhttpsonly.example.com:443'
'/VirtualHostRoot/test-path/deeper' '/VirtualHostRoot/test-path/deeper'
) )
self.assertEqual( self.assertEqual(
...@@ -2883,8 +2883,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2883,8 +2883,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.assertEqualResultJson( self.assertEqualResultJson(
result, result,
'Path', 'Path',
'/VirtualHostBase/http//' '/VirtualHostBase/http/'
'typezopeprefergzipencodingtobackendhttpsonly.example.com:80/' 'typezopeprefergzipencodingtobackendhttpsonly.example.com:80'
'/VirtualHostRoot/test-path/deeper' '/VirtualHostRoot/test-path/deeper'
) )
self.assertEqual( self.assertEqual(
...@@ -2911,8 +2911,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2911,8 +2911,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.assertEqualResultJson( self.assertEqualResultJson(
result, result,
'Path', 'Path',
'/VirtualHostBase/https//' '/VirtualHostBase/https/'
'typezopeprefergzipencodingtobackend.example.com:443/' 'typezopeprefergzipencodingtobackend.example.com:443'
'/VirtualHostRoot/test-path/deeper' '/VirtualHostRoot/test-path/deeper'
) )
...@@ -2949,8 +2949,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2949,8 +2949,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.assertEqualResultJson( self.assertEqualResultJson(
result, result,
'Path', 'Path',
'/VirtualHostBase/https//' '/VirtualHostBase/https/'
'typezopeprefergzipencodingtobackend.example.com:443/' 'typezopeprefergzipencodingtobackend.example.com:443'
'/VirtualHostRoot/test-path/deeper' '/VirtualHostRoot/test-path/deeper'
) )
self.assertEqual( self.assertEqual(
...@@ -2982,8 +2982,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2982,8 +2982,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.assertEqualResultJson( self.assertEqualResultJson(
result, result,
'Path', 'Path',
'/VirtualHostBase/http//typezopevirtualhostroothttpport' '/VirtualHostBase/http/typezopevirtualhostroothttpport'
'.example.com:12345//VirtualHostRoot/test-path' '.example.com:12345/VirtualHostRoot/test-path'
) )
def test_type_zope_virtualhostroot_https_port(self): def test_type_zope_virtualhostroot_https_port(self):
...@@ -3000,8 +3000,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3000,8 +3000,8 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.assertEqualResultJson( self.assertEqualResultJson(
result, result,
'Path', 'Path',
'/VirtualHostBase/https//typezopevirtualhostroothttpsport' '/VirtualHostBase/https/typezopevirtualhostroothttpsport'
'.example.com:12345//VirtualHostRoot/test-path' '.example.com:12345/VirtualHostRoot/test-path'
) )
def test_type_notebook(self): def test_type_notebook(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment