Revision 4e571185
b/snf-cyclades-app/synnefo/plankton/tests.py | ||
---|---|---|
251 | 251 |
{'owner': 'dummy_owner'}) |
252 | 252 |
|
253 | 253 |
@assert_backend_closed |
254 |
def test_add_image_invalid_name(self, backend): |
|
255 |
location = "pithos://uuid/container/name/" |
|
256 |
response = self.mypost("images/", |
|
257 |
json.dumps({}), |
|
258 |
'json', |
|
259 |
HTTP_X_IMAGE_META_NAME="\xc2", |
|
260 |
HTTP_X_IMAGE_META_OWNER='dummy_owner', |
|
261 |
HTTP_X_IMAGE_META_LOCATION=location) |
|
262 |
self.assertBadRequest(response) |
|
263 |
|
|
264 |
@assert_backend_closed |
|
254 | 265 |
def test_get_image(self, backend): |
255 | 266 |
response = self.myget("images/123") |
256 | 267 |
self.assertEqual(response.status_code, 501) |
b/snf-cyclades-app/synnefo/plankton/views.py | ||
---|---|---|
39 | 39 |
|
40 | 40 |
from django.conf import settings |
41 | 41 |
from django.http import HttpResponse |
42 |
from django.utils.encoding import smart_unicode, smart_str |
|
42 |
from django.utils.encoding import (smart_unicode, smart_str, |
|
43 |
DjangoUnicodeDecodeError) |
|
43 | 44 |
|
44 | 45 |
from snf_django.lib import api |
45 | 46 |
from snf_django.lib.api import faults |
... | ... | |
128 | 129 |
|
129 | 130 |
params = {} |
130 | 131 |
properties = {} |
131 |
for key, val in request.META.items(): |
|
132 |
if isinstance(val, basestring): |
|
133 |
val = decode_header(val) |
|
134 |
if is_img_property(key): |
|
135 |
key = decode_header(key[META_PROPERTY_PREFIX_LEN:]) |
|
136 |
properties[normalize(key)] = val |
|
137 |
elif is_img_param(key): |
|
138 |
key = decode_header(key[META_PREFIX_LEN:]) |
|
139 |
params[normalize(key)] = val |
|
132 |
try: |
|
133 |
for key, val in request.META.items(): |
|
134 |
if isinstance(val, basestring): |
|
135 |
val = decode_header(val) |
|
136 |
if is_img_property(key): |
|
137 |
key = decode_header(key[META_PROPERTY_PREFIX_LEN:]) |
|
138 |
properties[normalize(key)] = val |
|
139 |
elif is_img_param(key): |
|
140 |
key = decode_header(key[META_PREFIX_LEN:]) |
|
141 |
params[normalize(key)] = val |
|
142 |
except DjangoUnicodeDecodeError: |
|
143 |
raise faults.BadRequest("Could not decode request as UTF-8 string") |
|
140 | 144 |
|
141 | 145 |
if properties: |
142 | 146 |
params['properties'] = properties |
Also available in: Unified diff