Commit 16b037a9 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Remove http.HttpJsonConverter



With the move of the content-type handling to the various users of the HTTP
layer, this class isn't really useful anymore.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 627ad739
......@@ -59,7 +59,7 @@ class JsonErrorRequestExecutor(http.server.HttpServerRequestExecutor):
"""Custom Request Executor class that formats HTTP errors in JSON.
"""
error_content_type = http.HttpJsonConverter.CONTENT_TYPE
error_content_type = http.HTTP_APP_JSON
def _FormatErrorMessage(self, values):
"""Formats the body of an error message.
......@@ -174,8 +174,7 @@ class RemoteApiHttpServer(http.auth.HttpServerRequestAuthentication,
# treat it as type "application/octet-stream".
req_content_type = req.request_headers.get(http.HTTP_CONTENT_TYPE,
http.HTTP_APP_OCTET_STREAM)
if (req_content_type.lower() !=
http.HttpJsonConverter.CONTENT_TYPE.lower()):
if req_content_type.lower() != http.HTTP_APP_JSON.lower():
raise http.HttpUnsupportedMediaType()
try:
......@@ -196,8 +195,7 @@ class RemoteApiHttpServer(http.auth.HttpServerRequestAuthentication,
logging.exception("Error while handling the %s request", method)
raise
req.resp_headers[http.HTTP_CONTENT_TYPE] = \
http.HttpJsonConverter.CONTENT_TYPE
req.resp_headers[http.HTTP_CONTENT_TYPE] = http.HTTP_APP_JSON
return serializer.DumpJson(result)
......
......@@ -32,7 +32,6 @@ import errno
from cStringIO import StringIO
from ganeti import constants
from ganeti import serializer
from ganeti import utils
......@@ -67,6 +66,7 @@ HTTP_AUTHENTICATION_INFO = "Authentication-Info"
HTTP_ALLOW = "Allow"
HTTP_APP_OCTET_STREAM = "application/octet-stream"
HTTP_APP_JSON = "application/json"
_SSL_UNEXPECTED_EOF = "Unexpected EOF"
......@@ -323,18 +323,6 @@ class HttpVersionNotSupported(HttpException):
code = 505
class HttpJsonConverter: # pylint: disable-msg=W0232
CONTENT_TYPE = "application/json"
@staticmethod
def Encode(data):
return serializer.DumpJson(data)
@staticmethod
def Decode(data):
return serializer.LoadJson(data)
def WaitForSocketCondition(sock, event, timeout):
"""Waits for a condition to occur on the socket.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment