Add server type in OPTIONS response
Change-Id: I731872eaf2c878476525aa05fd60b9121be43e29
This commit is contained in:
parent
13f529ca81
commit
c8f02a8874
@ -44,6 +44,8 @@ from swift.common.request_helpers import is_sys_or_user_meta
|
||||
class AccountController(BaseStorageServer):
|
||||
"""WSGI controller for the account server."""
|
||||
|
||||
server_type = 'account-server'
|
||||
|
||||
def __init__(self, conf, logger=None):
|
||||
super(AccountController, self).__init__(conf)
|
||||
self.logger = logger or get_logger(conf, log_route='account-server')
|
||||
|
@ -14,6 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import inspect
|
||||
from swift import __version__ as swift_version
|
||||
from swift.common.utils import public, timing_stats, config_true_value
|
||||
from swift.common.swob import Response
|
||||
|
||||
@ -30,6 +31,11 @@ class BaseStorageServer(object):
|
||||
replication_server = config_true_value(replication_server)
|
||||
self.replication_server = replication_server
|
||||
|
||||
@property
|
||||
def server_type(self):
|
||||
raise NotImplementedError(
|
||||
'Storage nodes have not implemented the Server type.')
|
||||
|
||||
@property
|
||||
def allowed_methods(self):
|
||||
if self._allowed_methods is None:
|
||||
@ -64,7 +70,8 @@ class BaseStorageServer(object):
|
||||
:returns: swob.Response object
|
||||
"""
|
||||
# Prepare the default response
|
||||
headers = {'Allow': ', '.join(self.allowed_methods)}
|
||||
headers = {'Allow': ', '.join(self.allowed_methods),
|
||||
'Server': '%s/%s' % (self.server_type, swift_version)}
|
||||
resp = Response(status=200, request=req, headers=headers)
|
||||
|
||||
return resp
|
||||
|
@ -78,6 +78,7 @@ class ContainerController(BaseStorageServer):
|
||||
# Ensure these are all lowercase
|
||||
save_headers = ['x-container-read', 'x-container-write',
|
||||
'x-container-sync-key', 'x-container-sync-to']
|
||||
server_type = 'container-server'
|
||||
|
||||
def __init__(self, conf, logger=None):
|
||||
super(ContainerController, self).__init__(conf)
|
||||
|
@ -68,6 +68,8 @@ class EventletPlungerString(str):
|
||||
class ObjectController(BaseStorageServer):
|
||||
"""Implements the WSGI application for the Swift Object Server."""
|
||||
|
||||
server_type = 'object-server'
|
||||
|
||||
def __init__(self, conf, logger=None):
|
||||
"""
|
||||
Creates a new WSGI application for the Swift Object Server. An
|
||||
|
@ -28,6 +28,7 @@ import random
|
||||
import simplejson
|
||||
import xml.dom.minidom
|
||||
|
||||
from swift import __version__ as swift_version
|
||||
from swift.common.swob import Request
|
||||
from swift.common import constraints
|
||||
from swift.account.server import AccountController
|
||||
@ -66,6 +67,8 @@ class TestAccountController(unittest.TestCase):
|
||||
self.assertTrue(
|
||||
verb in resp.headers['Allow'].split(', '))
|
||||
self.assertEquals(len(resp.headers['Allow'].split(', ')), 7)
|
||||
self.assertEquals(resp.headers['Server'],
|
||||
(server_handler.server_type + '/' + swift_version))
|
||||
|
||||
def test_DELETE_not_found(self):
|
||||
req = Request.blank('/sda1/p/a', environ={'REQUEST_METHOD': 'DELETE',
|
||||
|
@ -31,6 +31,7 @@ import random
|
||||
from eventlet import spawn, Timeout, listen
|
||||
import simplejson
|
||||
|
||||
from swift import __version__ as swift_version
|
||||
from swift.common.swob import Request, HeaderKeyDict
|
||||
import swift.container
|
||||
from swift.container import server as container_server
|
||||
@ -312,6 +313,8 @@ class TestContainerController(unittest.TestCase):
|
||||
self.assertTrue(
|
||||
verb in resp.headers['Allow'].split(', '))
|
||||
self.assertEquals(len(resp.headers['Allow'].split(', ')), 7)
|
||||
self.assertEquals(resp.headers['Server'],
|
||||
(self.controller.server_type + '/' + swift_version))
|
||||
|
||||
def test_PUT(self):
|
||||
req = Request.blank(
|
||||
|
@ -38,6 +38,7 @@ from eventlet.green import httplib
|
||||
|
||||
from nose import SkipTest
|
||||
|
||||
from swift import __version__ as swift_version
|
||||
from test.unit import FakeLogger, debug_logger, mocked_http_conn
|
||||
from test.unit import connect_tcp, readuntil2crlfs, patch_policies
|
||||
from swift.obj import server as object_server
|
||||
@ -1136,6 +1137,8 @@ class TestObjectController(unittest.TestCase):
|
||||
self.assertTrue(
|
||||
verb in resp.headers['Allow'].split(', '))
|
||||
self.assertEquals(len(resp.headers['Allow'].split(', ')), 8)
|
||||
self.assertEquals(resp.headers['Server'],
|
||||
(server_handler.server_type + '/' + swift_version))
|
||||
|
||||
def test_GET(self):
|
||||
# Test swift.obj.server.ObjectController.GET
|
||||
|
Loading…
Reference in New Issue
Block a user