def _ensure_html_response(url, session):
    'Send a HEAD request to the URL, and ensure the response contains HTML.\n\n    Raises `_NotHTTP` if the URL is not available for a HEAD request, or\n    `_NotHTML` if the content type is not text/html.\n    '
    (scheme, netloc, path, query, fragment) = urllib_parse.urlsplit(url)
    if (scheme not in {'http', 'https'}):
        raise _NotHTTP()
    resp = session.head(url, allow_redirects=True)
    resp.raise_for_status()
    _ensure_html_header(resp)
Send a HEAD request to the URL, and ensure the response contains HTML.

Raises `_NotHTTP` if the URL is not available for a HEAD request, or
`_NotHTML` if the content type is not text/html.
def _ensure_html_response(url, session):
    'Send a HEAD request to the URL, and ensure the response contains HTML.\n\n    Raises `_NotHTTP` if the URL is not available for a HEAD request, or\n    `_NotHTML` if the content type is not text/html.\n    '
    (scheme, netloc, path, query, fragment) = urllib_parse.urlsplit(url)
    if (scheme not in {'http', 'https'}):
        raise _NotHTTP()
    resp = session.head(url, allow_redirects=True)
    resp.raise_for_status()
    _ensure_html_header(resp)