'Check response content and its type.
.. note::
Checking is not strict: wrong server response ``Content-Type``
HTTP header is ignored if response is an expected JSON object
(c.f. Boulder #56).
:param str content_type: Expected Content-Type response header.
If JSON is expected and not present in server response, this
function will raise an error. Otherwise, wrong Content-Type
is ignored, but logged.
:raises .messages.Error: If server response body
carries HTTP Problem (draft-ietf-appsawg-http-problem-00).
:raises .ClientError: In case of other networking errors.'

@classmethod
def _check_response(cls, response, content_type=None):

    response_ct = response.headers.get('Content-Type')
    try:
        jobj = response.json()
    except ValueError:
        jobj = None
    if (response.status_code == 409):
        raise errors.ConflictError(response.headers.get('Location'))
    if (not response.ok):
        if (jobj is not None):
            if (response_ct != cls.JSON_ERROR_CONTENT_TYPE):
                logger.debug('Ignoring    wrong    Content-Type    (%r)    for    JSON    Error', response_ct)
            try:
                raise messages.Error.from_json(jobj)
            except jose.DeserializationError as error:
                raise errors.ClientError((response, error))
        else:
            raise errors.ClientError(response)
    else:
        if ((jobj is not None) and (response_ct != cls.JSON_CONTENT_TYPE)):
            logger.debug('Ignoring    wrong    Content-Type    (%r)    for    JSON    decodable    response', response_ct)
        if ((content_type == cls.JSON_CONTENT_TYPE) and (jobj is None)):
            raise errors.ClientError('Unexpected    response    Content-Type:    {0}'.format(response_ct))
    return response
