diff --git a/caldav/davclient.py b/caldav/davclient.py index 4da3e6b..7d6b475 100644 --- a/caldav/davclient.py +++ b/caldav/davclient.py @@ -12,12 +12,12 @@ from typing import Union from urllib.parse import unquote -import niquests +import requests from lxml import etree from lxml.etree import _Element -from niquests.auth import AuthBase -from niquests.models import Response -from niquests.structures import CaseInsensitiveDict +from requests.auth import AuthBase +from requests.models import Response +from requests.structures import CaseInsensitiveDict from .elements.base import BaseElement from caldav import __version__ @@ -357,7 +357,7 @@ def expand_simple_props( class DAVClient: """ - Basic client for webdav, uses the niquests lib; gives access to + Basic client for webdav, uses the requests lib; gives access to low-level operations towards the caldav server. Unless you have special needs, you should probably care most about @@ -387,18 +387,18 @@ def __init__( * url: A fully qualified url: `scheme://user:pass@hostname:port` * proxy: A string defining a proxy server: `hostname:port` * username and password should be passed as arguments or in the URL - * auth, timeout and ssl_verify_cert are passed to niquests.request. + * auth, timeout and ssl_verify_cert are passed to requests.request. * ssl_verify_cert can be the path of a CA-bundle or False. * huge_tree: boolean, enable XMLParser huge_tree to handle big events, beware of security issues, see : https://lxml.de/api/lxml.etree.XMLParser-class.html - The niquests library will honor a .netrc-file, if such a file exists + The requests library will honor a .netrc-file, if such a file exists username and password may be omitted. Known bug: .netrc is honored even if a username/password is given, ref https://github.com/python-caldav/caldav/issues/206 """ headers = headers or {} - self.session = niquests.Session(multiplexed=True) + self.session = requests.Session() log.debug("url: " + str(url)) self.url = URL.objectify(url) @@ -406,7 +406,7 @@ def __init__( # Prepare proxy info if proxy is not None: _proxy = proxy - # niquests library expects the proxy url to have a scheme + # requests library expects the proxy url to have a scheme if "://" not in proxy: _proxy = self.url.scheme + "://" + proxy @@ -700,9 +700,9 @@ def request( auth_types = self.extract_auth_types(r.headers["WWW-Authenticate"]) if self.password and self.username and "digest" in auth_types: - self.auth = niquests.auth.HTTPDigestAuth(self.username, self.password) + self.auth = requests.auth.HTTPDigestAuth(self.username, self.password) elif self.password and self.username and "basic" in auth_types: - self.auth = niquests.auth.HTTPBasicAuth(self.username, self.password) + self.auth = requests.auth.HTTPBasicAuth(self.username, self.password) elif self.password and "bearer" in auth_types: self.auth = HTTPBearerAuth(self.password) else: @@ -732,11 +732,11 @@ def request( auth_types = self.extract_auth_types(r.headers["WWW-Authenticate"]) if self.password and self.username and "digest" in auth_types: - self.auth = niquests.auth.HTTPDigestAuth( + self.auth = requests.auth.HTTPDigestAuth( self.username, self.password.decode() ) elif self.password and self.username and "basic" in auth_types: - self.auth = niquests.auth.HTTPBasicAuth( + self.auth = requests.auth.HTTPBasicAuth( self.username, self.password.decode() ) elif self.password and "bearer" in auth_types: @@ -748,8 +748,8 @@ def request( # this is an error condition that should be raised to the application if ( - response.status == niquests.codes.forbidden - or response.status == niquests.codes.unauthorized + response.status == requests.codes.forbidden + or response.status == requests.codes.unauthorized ): try: reason = response.reason diff --git a/caldav/requests.py b/caldav/requests.py index 265ec40..0d0c330 100644 --- a/caldav/requests.py +++ b/caldav/requests.py @@ -1,4 +1,4 @@ -from niquests.auth import AuthBase +from requests.auth import AuthBase class HTTPBearerAuth(AuthBase): diff --git a/pyproject.toml b/pyproject.toml index 2a93374..539fb29 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,45 +10,44 @@ description = "CalDAV (RFC4791) client library" keywords = [] readme = "README.md" classifiers = [ - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "License :: OSI Approved :: GNU General Public License (GPL)", - "License :: OSI Approved :: Apache Software License", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "Topic :: Office/Business :: Scheduling", - "Topic :: Software Development :: Libraries :: Python Modules", + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU General Public License (GPL)", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Office/Business :: Scheduling", + "Topic :: Software Development :: Libraries :: Python Modules", ] urls = { Homepage = "https://github.com/python-caldav/caldav" } dependencies = [ - "vobject", - "lxml", - "niquests", - "recurring-ical-events>=2.0.0", - "typing_extensions;python_version<'3.11'", - ## It's a mess - newer versions of xandikos, used for testing, does not support python 3.8 anymore. icalendar 6.0.0 is not compatible with elder versions of xandikos. It's no problem with python 3.7, as icalender 6.0.0 does not support python 3.7. - "icalendar<6.0.0;python_version=='3.8'", - "icalendar;python_version!='3.8'", + "vobject", + "lxml", + "requests", + "recurring-ical-events>=2.0.0", + "typing_extensions;python_version<'3.11'", + ## It's a mess - newer versions of xandikos, used for testing, does not support python 3.8 anymore. icalendar 6.0.0 is not compatible with elder versions of xandikos. It's no problem with python 3.7, as icalender 6.0.0 does not support python 3.7. + "icalendar<6.0.0;python_version=='3.8'", + "icalendar;python_version!='3.8'", ] dynamic = ["version"] [project.optional-dependencies] test = [ - "pytest", - "coverage", - "sphinx", - "backports.zoneinfo;python_version<'3.9'", - "tzlocal", - "xandikos==0.2.7;python_version<'3.9'", - "dulwich==0.20.50;python_version<'3.9'", - "xandikos;python_version>='3.9'", + "pytest", + "coverage", + "sphinx", + "backports.zoneinfo;python_version<'3.9'", + "tzlocal", + "xandikos==0.2.7;python_version<'3.9'", + "dulwich==0.20.50;python_version<'3.9'", + "xandikos;python_version>='3.9'", ] [tool.setuptools_scm] diff --git a/tests/conf.py b/tests/conf.py index b777b33..14e4926 100644 --- a/tests/conf.py +++ b/tests/conf.py @@ -8,7 +8,7 @@ import threading import time -import niquests +import requests from . import compatibility_issues from caldav.davclient import DAVClient @@ -117,7 +117,7 @@ def setup_radicale(self): i = 0 while True: try: - niquests.get(self.url) + requests.get(self.url) break except: time.sleep(0.05) @@ -197,7 +197,7 @@ def teardown_xandikos(self): ## ... but the thread may be stuck waiting for a request ... def silly_request(): try: - niquests.get(self.url) + requests.get(self.url) except: pass diff --git a/tests/test_caldav.py b/tests/test_caldav.py index 05314bf..829345f 100644 --- a/tests/test_caldav.py +++ b/tests/test_caldav.py @@ -24,6 +24,7 @@ import icalendar import pytest import vobject +from requests.packages import urllib3 from . import compatibility_issues from .conf import caldav_servers @@ -59,6 +60,7 @@ log = logging.getLogger("caldav") +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) ev1 = """BEGIN:VCALENDAR VERSION:2.0 diff --git a/tests/test_caldav_unit.py b/tests/test_caldav_unit.py index cf3fbdd..d795756 100644 --- a/tests/test_caldav_unit.py +++ b/tests/test_caldav_unit.py @@ -251,7 +251,7 @@ class TestCalDAV: dependencies, without accessing any caldav server) """ - @mock.patch("caldav.davclient.niquests.Session.request") + @mock.patch("caldav.davclient.requests.Session.request") def testRequestNonAscii(self, mocked): """ ref https://github.com/python-caldav/caldav/issues/83 @@ -272,7 +272,7 @@ def testRequestNonAscii(self, mocked): assert response.status == 200 assert response.tree is None - @mock.patch("caldav.davclient.niquests.Session.request") + @mock.patch("caldav.davclient.requests.Session.request") def testRequestCustomHeaders(self, mocked): """ ref https://github.com/python-caldav/caldav/issues/285 @@ -290,7 +290,7 @@ def testRequestCustomHeaders(self, mocked): ## User-Agent would be overwritten by some boring default in earlier versions assert client.headers["User-Agent"] == "MyCaldavApp" - @mock.patch("caldav.davclient.niquests.Session.request") + @mock.patch("caldav.davclient.requests.Session.request") def testRequestUserAgent(self, mocked): """ ref https://github.com/python-caldav/caldav/issues/391 @@ -304,7 +304,7 @@ def testRequestUserAgent(self, mocked): assert client.headers["Content-Type"] == "text/xml" assert client.headers["User-Agent"].startswith("python-caldav/") - @mock.patch("caldav.davclient.niquests.Session.request") + @mock.patch("caldav.davclient.requests.Session.request") def testEmptyXMLNoContentLength(self, mocked): """ ref https://github.com/python-caldav/caldav/issues/213 @@ -314,7 +314,7 @@ def testEmptyXMLNoContentLength(self, mocked): mocked().content = "" client = DAVClient(url="AsdfasDF").request("/") - @mock.patch("caldav.davclient.niquests.Session.request") + @mock.patch("caldav.davclient.requests.Session.request") def testNonValidXMLNoContentLength(self, mocked): """ If XML is expected but nonvalid XML is given, an error should be raised