diff options
author | Mark Rawlings <Mark.Rawlings@hp.com> | 2015-03-03 18:03:58 +0000 |
---|---|---|
committer | Mark Rawlings <Mark.Rawlings@hp.com> | 2015-03-09 16:37:49 +0000 |
commit | 4b6ed760d4303744907feefd81e60f38ae3750ef (patch) | |
tree | d8019d0bcaacda66a10c7ae3ce13184f8c3aae8b /neutronclient/v2_0 | |
parent | c964a12e01b115afcab40849ea72aa0eddc9b3dc (diff) | |
download | python-neutronclient-4b6ed760d4303744907feefd81e60f38ae3750ef.tar.gz |
Reinstate Max URI length checking to V2_0 Client
A previous commit 799e288f48e5d99731dedbfb94808a8cbe01c05c
has broken the ability to recognise long URIs (>8192) and
raise an exception used to prevent the excessive URI being sent
to the server. This impacts the commands net-list and
security-group-rule-list.
The previous edit removed one of the duplicate _check_uri_length functions.
This edit 'swaps' the removal and updates the unit test stubbing accordingly.
The capability to split excessive URIs into managable chunks remained in
the code, but no longer executed because this exception was not raised.
It should be noted that as a side effect of recognising the
long URI, data is returned with the exception that indicates
'how excessive' the URI length was. This allows the URI to be
broken into chunks that will be supported.
Restore the capability to recognise that an excessive URI has
been provided and to raise the expected exception with
related data.
Closes-Bug: #1422736
Change-Id: I1b719bed406b83c5f2deac06e127798a91f51ad7
Diffstat (limited to 'neutronclient/v2_0')
-rw-r--r-- | neutronclient/v2_0/client.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/neutronclient/v2_0/client.py b/neutronclient/v2_0/client.py index 0feac68..2e63bb2 100644 --- a/neutronclient/v2_0/client.py +++ b/neutronclient/v2_0/client.py @@ -184,6 +184,12 @@ class ClientBase(object): # Raise the appropriate exception exception_handler_v20(status_code, des_error_body) + def _check_uri_length(self, action): + uri_len = len(self.httpclient.endpoint_url) + len(action) + if uri_len > self.MAX_URI_LEN: + raise exceptions.RequestURITooLong( + excess=uri_len - self.MAX_URI_LEN) + def do_request(self, method, action, body=None, headers=None, params=None): # Add format and tenant_id action += ".%s" % self.format @@ -192,6 +198,8 @@ class ClientBase(object): params = utils.safe_encode_dict(params) action += '?' + urlparse.urlencode(params, doseq=1) + self._check_uri_length(action) + if body: body = self.serialize(body) @@ -456,6 +464,9 @@ class Client(ClientBase): 'healthmonitors': 'healthmonitor', } + # 8192 Is the default max URI len for eventlet.wsgi.server + MAX_URI_LEN = 8192 + @APIParamsCall def list_ext(self, path, **_params): """Client extension hook for lists. |