Skip to content

Commit a6c39da

Browse files
committed
Reverting the niquests library - release version 1.5 should not introduce such dependency-changes
1 parent 75aabf0 commit a6c39da

6 files changed

Lines changed: 27 additions & 26 deletions

File tree

caldav/davclient.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
from typing import Union
1414
from urllib.parse import unquote
1515

16-
import niquests
16+
import requests
1717
from lxml import etree
1818
from lxml.etree import _Element
19-
from niquests.auth import AuthBase
20-
from niquests.models import Response
21-
from niquests.structures import CaseInsensitiveDict
19+
from requests.auth import AuthBase
20+
from requests.models import Response
21+
from requests.structures import CaseInsensitiveDict
2222

2323
from .elements.base import BaseElement
2424
from caldav import __version__
@@ -402,7 +402,7 @@ def expand_simple_props(
402402

403403
class DAVClient:
404404
"""
405-
Basic client for webdav, uses the niquests lib; gives access to
405+
Basic client for webdav, uses the requests lib; gives access to
406406
low-level operations towards the caldav server.
407407
408408
Unless you have special needs, you should probably care most about
@@ -432,26 +432,26 @@ def __init__(
432432
* url: A fully qualified url: `scheme://user:pass@hostname:port`
433433
* proxy: A string defining a proxy server: `hostname:port`
434434
* username and password should be passed as arguments or in the URL
435-
* auth, timeout and ssl_verify_cert are passed to niquests.request.
435+
* auth, timeout and ssl_verify_cert are passed to requests.request.
436436
* ssl_verify_cert can be the path of a CA-bundle or False.
437437
* huge_tree: boolean, enable XMLParser huge_tree to handle big events, beware
438438
of security issues, see : https://lxml.de/api/lxml.etree.XMLParser-class.html
439439
440-
The niquests library will honor a .netrc-file, if such a file exists
440+
The requests library will honor a .netrc-file, if such a file exists
441441
username and password may be omitted. Known bug: .netrc is honored
442442
even if a username/password is given, ref https://github.com/python-caldav/caldav/issues/206
443443
"""
444444
headers = headers or {}
445445

446-
self.session = niquests.Session(multiplexed=True)
446+
self.session = requests.Session()
447447

448448
log.debug("url: " + str(url))
449449
self.url = URL.objectify(url)
450450
self.huge_tree = huge_tree
451451
# Prepare proxy info
452452
if proxy is not None:
453453
_proxy = proxy
454-
# niquests library expects the proxy url to have a scheme
454+
# requests library expects the proxy url to have a scheme
455455
if "://" not in proxy:
456456
_proxy = self.url.scheme + "://" + proxy
457457

@@ -747,11 +747,10 @@ def request(
747747
and self.username
748748
):
749749
auth_types = self.extract_auth_types(r_headers["WWW-Authenticate"])
750-
751750
if self.username and "digest" in auth_types:
752-
self.auth = niquests.auth.HTTPDigestAuth(self.username, self.password)
751+
self.auth = requests.auth.HTTPDigestAuth(self.username, self.password)
753752
elif self.username and "basic" in auth_types:
754-
self.auth = niquests.auth.HTTPBasicAuth(self.username, self.password)
753+
self.auth = requests.auth.HTTPBasicAuth(self.username, self.password)
755754
elif self.password and "bearer" in auth_types:
756755
self.auth = HTTPBearerAuth(self.password)
757756
elif "bearer" in auth_types:
@@ -785,11 +784,11 @@ def request(
785784
auth_types = self.extract_auth_types(r_headers["WWW-Authenticate"])
786785

787786
if self.password and self.username and "digest" in auth_types:
788-
self.auth = niquests.auth.HTTPDigestAuth(
787+
self.auth = requests.auth.HTTPDigestAuth(
789788
self.username, self.password.decode()
790789
)
791790
elif self.password and self.username and "basic" in auth_types:
792-
self.auth = niquests.auth.HTTPBasicAuth(
791+
self.auth = requests.auth.HTTPBasicAuth(
793792
self.username, self.password.decode()
794793
)
795794
elif self.password and "bearer" in auth_types:
@@ -801,8 +800,8 @@ def request(
801800

802801
# this is an error condition that should be raised to the application
803802
if (
804-
response.status == niquests.codes.forbidden
805-
or response.status == niquests.codes.unauthorized
803+
response.status == requests.codes.forbidden
804+
or response.status == requests.codes.unauthorized
806805
):
807806
try:
808807
reason = response.reason

caldav/requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from niquests.auth import AuthBase
1+
from requests.auth import AuthBase
22

33

44
class HTTPBearerAuth(AuthBase):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ classifiers = [
3030
dependencies = [
3131
"vobject",
3232
"lxml",
33-
"niquests",
33+
"requests",
3434
"recurring-ical-events>=2.0.0",
3535
"typing_extensions;python_version<'3.11'",
3636
## 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.

tests/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import threading
99
import time
1010

11-
import niquests
11+
import requests
1212

1313
from caldav import compatibility_hints
1414
from caldav.davclient import CONNKEYS
@@ -127,7 +127,7 @@ def setup_radicale(self):
127127
i = 0
128128
while True:
129129
try:
130-
niquests.get(str(self.url))
130+
requests.get(str(self.url))
131131
break
132132
except:
133133
time.sleep(0.05)
@@ -207,7 +207,7 @@ def teardown_xandikos(self):
207207
## ... but the thread may be stuck waiting for a request ...
208208
def silly_request():
209209
try:
210-
niquests.get(str(self.url))
210+
requests.get(str(self.url))
211211
except:
212212
pass
213213

tests/test_caldav.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import icalendar
2525
import pytest
2626
import vobject
27+
from requests.packages import urllib3
2728

2829
from .conf import caldav_servers
2930
from .conf import client
@@ -59,6 +60,7 @@
5960

6061
log = logging.getLogger("caldav")
6162

63+
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
6264

6365
ev1 = """BEGIN:VCALENDAR
6466
VERSION:2.0

tests/test_caldav_unit.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ class TestCalDAV:
366366
dependencies, without accessing any caldav server)
367367
"""
368368

369-
@mock.patch("caldav.davclient.niquests.Session.request")
369+
@mock.patch("caldav.davclient.requests.Session.request")
370370
def testRequestNonAscii(self, mocked):
371371
"""
372372
ref https://github.com/python-caldav/caldav/issues/83
@@ -423,7 +423,7 @@ def testLoadByMultiGet404(self):
423423
with pytest.raises(error.NotFoundError):
424424
object.load_by_multiget()
425425

426-
@mock.patch("caldav.davclient.niquests.Session.request")
426+
@mock.patch("caldav.davclient.requests.Session.request")
427427
def testRequestCustomHeaders(self, mocked):
428428
"""
429429
ref https://github.com/python-caldav/caldav/issues/285
@@ -441,7 +441,7 @@ def testRequestCustomHeaders(self, mocked):
441441
## User-Agent would be overwritten by some boring default in earlier versions
442442
assert client.headers["User-Agent"] == "MyCaldavApp"
443443

444-
@mock.patch("caldav.davclient.niquests.Session.request")
444+
@mock.patch("caldav.davclient.requests.Session.request")
445445
def testRequestUserAgent(self, mocked):
446446
"""
447447
ref https://github.com/python-caldav/caldav/issues/391
@@ -455,7 +455,7 @@ def testRequestUserAgent(self, mocked):
455455
assert client.headers["Content-Type"] == "text/xml"
456456
assert client.headers["User-Agent"].startswith("python-caldav/")
457457

458-
@mock.patch("caldav.davclient.niquests.Session.request")
458+
@mock.patch("caldav.davclient.requests.Session.request")
459459
def testEmptyXMLNoContentLength(self, mocked):
460460
"""
461461
ref https://github.com/python-caldav/caldav/issues/213
@@ -465,7 +465,7 @@ def testEmptyXMLNoContentLength(self, mocked):
465465
mocked().content = ""
466466
client = DAVClient(url="AsdfasDF").request("/")
467467

468-
@mock.patch("caldav.davclient.niquests.Session.request")
468+
@mock.patch("caldav.davclient.requests.Session.request")
469469
def testNonValidXMLNoContentLength(self, mocked):
470470
"""
471471
If XML is expected but nonvalid XML is given, an error should be raised

0 commit comments

Comments
 (0)