NTLM Authentication - urllib3 1.26.15 documentation

Hide navigation sidebar
Hide table of contents sidebar
Support urllib3 on GitHub Sponsors
Back to top
Toggle table of contents sidebar

# NTLM Authentication

NTLM authenticating pool, contributed by erikcederstran

Issue #10, see: http://code.google.com/p/urllib3/issues/detail?id=10

class urllib3.contrib.ntlmpool.NTLMConnectionPool(user, pw, authurl, *args, **kwargs)

  Bases: `HTTPSConnectionPool`

  Implements an NTLM authentication version of an urllib3 connection pool

  scheme = 'https'
  urlopen(method, url, body=None, headers=None, retries=3, redirect=True, assert_same_host=True)

    Get a connection from the pool and perform an HTTP request. This is the lowest level call for making a request, so you’ll need to specify all the raw details.

    Note

    More commonly, it’s appropriate to use a convenience method provided by `RequestMethods`, such as `request()`.

    Note

    release_conn will only behave as expected if preload_content=False because we want to make preload_content=False the default behaviour someday soon without breaking backwards compatibility.

    Parameters:

      - method – HTTP request method (such as GET, POST, PUT, etc.)

      - url – The URL to perform the request on.

      - body – Data to send in the request body, either `str`, `bytes`, an iterable of `str`/`bytes`, or a file-like object.

      - headers – Dictionary of custom headers to send, such as User-Agent, If-None-Match, etc. If None, pool headers are used. If provided, these headers completely replace any pool-specific headers.

      - retries (`Retry`, False, or an int.) –

        Configure the number of retries to allow before raising a `MaxRetryError` exception.

        Pass `None` to retry until you receive a response. Pass a `Retry` object for fine-grained control over different types of retries. Pass an integer number to retry connection errors that many times, but no other types of errors. Pass zero to never retry.

        If `False`, then retries are disabled and any exception is raised immediately. Also, instead of raising a MaxRetryError on redirects, the redirect response will be returned.

      - redirect – If True, automatically handle redirects (status codes 301, 302, 303, 307, 308). Each redirect counts as a retry. Disabling retries will disable redirect, too.

      - assert_same_host – If `True`, will make sure that the host of the pool requests is consistent else will raise HostChangedError. When `False`, you can use the pool on an HTTP proxy and request foreign hosts.

      - timeout – If specified, overrides the default timeout for this one request. It may be a float (in seconds) or an instance of `urllib3.util.Timeout`.

      - pool_timeout – If set and the pool is set to block=True, then this method will block for `pool_timeout` seconds and raise EmptyPoolError if no connection is available within the time period.

      - release_conn – If False, then the urlopen call will not release the connection back into the pool once a response is received (but will release if you read the entire contents of the response such as when preload_content=True). This is useful if you’re not preloading the response’s content immediately. You will need to call `r.release_conn()` on the response `r` to return the connection back into the pool. If None, it takes the value of `response_kw.get('preload_content', True)`.

      - chunked – If True, urllib3 will send the body using chunked transfer encoding. Otherwise, urllib3 will send the body using the standard content-length form. Defaults to False.

      - body_pos (int) – Position to seek to in file-like body in the event of a retry or redirect. Typically this won’t need to be set because urllib3 will auto-populate the value when needed.

      - **response_kw – Additional parameters are passed to `urllib3.response.HTTPResponse.from_httplib()`