protected function checkConsume(\SwaggerValidator\Common\Context $context)
    {
        if (!isset($this->consume)) {
            return true;
        }

        $headers       = $context->getRequestHeader();
        $contentType   = null;
        $contentLength = 0;

        if (array_key_exists('Content-Type', $headers)) {
            $contentType = explode(';', $headers['Content-Type']);
            $contentType = str_replace(array('application/', 'text/', 'x-'), '', array_shift($contentType));
        }

        if (array_key_exists('Content-Length', $headers)) {
            $contentLength = (int) $headers['Content-Length'];
        }

        if (empty($contentType) && $contentLength === 0) {
            return true;
        }

        foreach ($this->consume as $oneContentType) {
            $oneContentType = explode(';', $oneContentType);
            $oneContentType = str_replace(array('application/', 'text/', 'x-'), '', array_shift($oneContentType));

            if (strtolower($contentType) == strtolower($oneContentType)) {
                return true;
            }
        }

        return $context->setValidationError(\SwaggerValidator\Common\Context::VALIDATION_TYPE_DATAVALUE, 'Content-Type requested is not allowed', __METHOD__, __LINE__);
    }