Revision 16b037a9 daemons/ganeti-rapi
b/daemons/ganeti-rapi | ||
---|---|---|
59 | 59 |
"""Custom Request Executor class that formats HTTP errors in JSON. |
60 | 60 |
|
61 | 61 |
""" |
62 |
error_content_type = http.HttpJsonConverter.CONTENT_TYPE
|
|
62 |
error_content_type = http.HTTP_APP_JSON
|
|
63 | 63 |
|
64 | 64 |
def _FormatErrorMessage(self, values): |
65 | 65 |
"""Formats the body of an error message. |
... | ... | |
174 | 174 |
# treat it as type "application/octet-stream". |
175 | 175 |
req_content_type = req.request_headers.get(http.HTTP_CONTENT_TYPE, |
176 | 176 |
http.HTTP_APP_OCTET_STREAM) |
177 |
if (req_content_type.lower() != |
|
178 |
http.HttpJsonConverter.CONTENT_TYPE.lower()): |
|
177 |
if req_content_type.lower() != http.HTTP_APP_JSON.lower(): |
|
179 | 178 |
raise http.HttpUnsupportedMediaType() |
180 | 179 |
|
181 | 180 |
try: |
... | ... | |
196 | 195 |
logging.exception("Error while handling the %s request", method) |
197 | 196 |
raise |
198 | 197 |
|
199 |
req.resp_headers[http.HTTP_CONTENT_TYPE] = \ |
|
200 |
http.HttpJsonConverter.CONTENT_TYPE |
|
198 |
req.resp_headers[http.HTTP_CONTENT_TYPE] = http.HTTP_APP_JSON |
|
201 | 199 |
|
202 | 200 |
return serializer.DumpJson(result) |
203 | 201 |
|
Also available in: Unified diff