Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def _get_key(self, env, account):
- """
- Returns the X-Account-Meta-Temp-URL-Key header value for the
- account, or None if none is set.
- :param env: The WSGI environment for the request.
- :param account: Account str.
- :returns: X-Account-Meta-Temp-URL-Key str value, or None.
- """
- key = None
- memcache = env.get('swift.cache')
- if memcache:
- key = memcache.get('temp-url-key/%s' % account)
- if not key:
- newenv = {'REQUEST_METHOD': 'HEAD', 'SCRIPT_NAME': '',
- 'PATH_INFO': '/v1/' + account, 'CONTENT_LENGTH': '0',
- 'SERVER_PROTOCOL': 'HTTP/1.0',
- 'HTTP_USER_AGENT': 'TempURL', 'wsgi.version': (1, 0),
- 'wsgi.url_scheme': 'http', 'wsgi.input': StringIO('')}
- for name in ('SERVER_NAME', 'SERVER_PORT', 'wsgi.errors',
- 'wsgi.multithread', 'wsgi.multiprocess',
- 'wsgi.run_once', 'swift.cache', 'swift.trans_id'):
- if name in env:
- newenv[name] = env[name]
- newenv['swift.authorize'] = lambda req: None
- newenv['swift.authorize_override'] = True
- newenv['REMOTE_USER'] = '.wsgi.tempurl'
- key = [None]
- def _start_response(status, response_headers, exc_info=None):
- for h, v in response_headers:
- if h.lower() == 'x-account-meta-temp-url-key':
- key[0] = v
- self.logger.debug("env: %s" % str(env))
- self.logger.debug("new: %s" % str(newenv))
- self.app(newenv, _start_response)
- self.logger.debug("key: %s" % str(key))
- key = key[0]
- if key and memcache:
- memcache.set('temp-url-key/%s' % account, key, timeout=60)
- return key
- -----
- May 8 15:41:37 SwiftTest proxy-server env: {'webob._parsed_query_vars': (GET([('temp_url_sig', '440638f0fb33bc955197408a6a15e9fb5ce2adf8'), ('temp_url_expires', '1336507058')]), 'temp_url_sig=440638f0fb33bc955197408a6a15e9fb5ce2adf8&temp_url_expires=1336507058'), 'SCRIPT_NAME': '', 'REQUEST_METHOD': 'GET', 'PATH_INFO': '/v1/admin/curl_container/TEST_README', 'SERVER_PROTOCOL': 'HTTP/1.0', 'QUERY_STRING': 'temp_url_sig=440638f0fb33bc955197408a6a15e9fb5ce2adf8&temp_url_expires=1336507058', 'HTTP_USER_AGENT': 'curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3', 'eventlet.posthooks': [], 'SERVER_NAME': '10.150.1.61', 'REMOTE_ADDR': '10.150.1.61', 'eventlet.input': <eventlet.wsgi.Input object at 0x2077d90>, 'wsgi.url_scheme': 'http', 'SERVER_PORT': '8080', 'wsgi.input': <eventlet.wsgi.Input object at 0x2077d90>, 'HTTP_HOST': '10.150.1.61:8080', 'wsgi.multithread': True, 'HTTP_ACCEPT': '*/*', 'wsgi.version': (1, 0), 'GATEWAY_INTERFACE': 'CGI/1.1', 'wsgi.run_once': False, 'wsgi.errors': <swift.common.utils.LoggerFileObject object at 0x206ee50>, 'wsgi.multiprocess': False, 'swift.trans_id': 'txfcb89c0e9f3f405abffeecefd1ab7aa6', 'CONTENT_TYPE': None, 'swift.cache': <swift.common.memcached.MemcacheRing object at 0x2095e90>}
- May 8 15:41:37 SwiftTest proxy-server new: {'wsgi.multithread': True, 'SCRIPT_NAME': '', 'wsgi.input': <StringIO.StringIO instance at 0x2062d88>, 'REQUEST_METHOD': 'HEAD', 'PATH_INFO': '/v1/admin', 'SERVER_PROTOCOL': 'HTTP/1.0', 'swift.authorize': <function <lambda> at 0x207d410>, 'CONTENT_LENGTH': '0', 'HTTP_USER_AGENT': 'TempURL', 'wsgi.version': (1, 0), 'SERVER_NAME': '10.150.1.61', 'wsgi.run_once': False, 'wsgi.errors': <swift.common.utils.LoggerFileObject object at 0x206ee50>, 'wsgi.multiprocess': False, 'swift.trans_id': 'txfcb89c0e9f3f405abffeecefd1ab7aa6', 'wsgi.url_scheme': 'http', 'REMOTE_USER': '.wsgi.tempurl', 'SERVER_PORT': '8080', 'swift.cache': <swift.common.memcached.MemcacheRing object at 0x2095e90>, 'swift.authorize_override': True}
- May 8 15:41:37 SwiftTest proxy-server key: [None]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement