Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
9ce49d95
Commit
9ce49d95
authored
Jan 11, 2005
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Collector #1657: preserve 'Host:' header when PURGEing the accelerator cache.
parent
59859036
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
123 additions
and
6 deletions
+123
-6
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
...ucts/StandardCacheManagers/AcceleratedHTTPCacheManager.py
+4
-6
lib/python/Products/StandardCacheManagers/tests/__init__.py
lib/python/Products/StandardCacheManagers/tests/__init__.py
+17
-0
lib/python/Products/StandardCacheManagers/tests/test_AcceleratedHTTPCacheManager.py
...rdCacheManagers/tests/test_AcceleratedHTTPCacheManager.py
+99
-0
No files found.
doc/CHANGES.txt
View file @
9ce49d95
...
...
@@ -51,6 +51,9 @@ Zope Changes
Bugs fixed
- Collector #1657: Don't break host-based virtual hosting when
purging an HTTP accelerator.
- DTML Methods were not interoperable with the new filestream_iterator
and caches based on it (FileCacheManager).
...
...
lib/python/Products/StandardCacheManagers/AcceleratedHTTPCacheManager.py
View file @
9ce49d95
...
...
@@ -62,12 +62,10 @@ class AcceleratedHTTPCache (Cache):
p
=
path
[:
-
1
]
+
ob_path
else
:
p
=
path
+
ob_path
h
=
httplib
.
HTTP
(
host
)
h
.
putrequest
(
'PURGE'
,
p
)
h
.
endheaders
()
errcode
,
errmsg
,
headers
=
h
.
getreply
()
h
.
getfile
().
read
()
# Mandatory for httplib?
results
.
append
(
'%s %s'
%
(
errcode
,
errmsg
))
h
=
httplib
.
HTTPConnection
(
host
)
h
.
request
(
'PURGE'
,
p
)
r
=
h
.
getresponse
()
results
.
append
(
'%s %s'
%
(
r
.
status
,
r
.
reason
))
return
'Server response(s): '
+
';'
.
join
(
results
)
def
ZCache_get
(
self
,
ob
,
view_name
,
keywords
,
mtime_func
,
default
):
...
...
lib/python/Products/StandardCacheManagers/tests/__init__.py
0 → 100644
View file @
9ce49d95
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
""" Unit tests for StandardCacheManagers product.
$Id$
"""
lib/python/Products/StandardCacheManagers/tests/test_AcceleratedHTTPCacheManager.py
0 → 100644
View file @
9ce49d95
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
""" Unit tests for AcceleratedCacheManager module.
$Id$
"""
import
unittest
import
threading
from
SimpleHTTPServer
import
SimpleHTTPRequestHandler
from
BaseHTTPServer
import
HTTPServer
class
PurgingHTTPRequestHandler
(
SimpleHTTPRequestHandler
):
protocol_version
=
'HTTP/1.0'
def
do_PURGE
(
self
):
"""Serve a PURGE request."""
self
.
server
.
test_case
.
purged_host
=
self
.
headers
.
get
(
'Host'
,
'xxx'
)
self
.
server
.
test_case
.
purged_path
=
self
.
path
self
.
send_response
(
200
)
self
.
end_headers
()
def
log_request
(
self
,
code
=
'ignored'
,
size
=
'ignored'
):
pass
class
DummyObject
:
_PATH
=
'/path/to/object'
def
getPhysicalPath
(
self
):
return
tuple
(
self
.
_PATH
.
split
(
'/'
))
class
AcceleratedHTTPCacheTests
(
unittest
.
TestCase
):
_SERVER_PORT
=
1888
thread
=
purged_host
=
purged_path
=
None
def
tearDown
(
self
):
if
self
.
thread
:
self
.
httpd
.
server_close
()
self
.
thread
.
join
()
def
_getTargetClass
(
self
):
from
Products.StandardCacheManagers.AcceleratedHTTPCacheManager
\
import
AcceleratedHTTPCache
return
AcceleratedHTTPCache
def
_makeOne
(
self
,
*
args
,
**
kw
):
return
self
.
_getTargetClass
()(
*
args
,
**
kw
)
def
_handleServerRequest
(
self
):
server_address
=
(
''
,
self
.
_SERVER_PORT
)
self
.
httpd
=
HTTPServer
(
server_address
,
PurgingHTTPRequestHandler
)
self
.
httpd
.
test_case
=
self
sa
=
self
.
httpd
.
socket
.
getsockname
()
self
.
thread
=
threading
.
Thread
(
target
=
self
.
httpd
.
handle_request
)
self
.
thread
.
start
()
def
test_PURGE_passes_Host_header
(
self
):
_TO_NOTIFY
=
'localhost:%d'
%
self
.
_SERVER_PORT
cache
=
self
.
_makeOne
()
cache
.
notify_urls
=
[
'http://%s'
%
_TO_NOTIFY
]
object
=
DummyObject
()
# Run the HTTP server for this test.
self
.
_handleServerRequest
()
cache
.
ZCache_invalidate
(
object
)
self
.
assertEqual
(
self
.
purged_host
,
_TO_NOTIFY
)
self
.
assertEqual
(
self
.
purged_path
,
DummyObject
.
_PATH
)
def
test_suite
():
return
unittest
.
makeSuite
(
AcceleratedHTTPCacheTests
)
if
__name__
==
'__main__'
:
unittest
.
main
(
defaultTest
=
'test_suite'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment