Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dev = [
"types-orjson>=3.6.2",
"types-python-dateutil>=2.9.0.20241003",
"types-urllib3>=1.26.25.14",
"urllib3>=2.3.0",
"urllib3>=1.26.19",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To test this change I set this to "urllib3==1.26.19", locally and ran tests.

"virtualenv>=20.26.6",
]
docs = [
Expand Down
9 changes: 5 additions & 4 deletions pystac/stac_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ def read_text_from_href(self, href: str) -> str:
"""Reads file as a UTF-8 string.

If ``href`` has a "scheme" (e.g. if it starts with "https://") then this will
use :func:`urllib.request.urlopen` (or func:`urllib3.request` if available)
to open the file and read the contents; otherwise, :func:`open` will be used
to open a local file.
use :func:`urllib.request.urlopen` (or func:`urllib3.PoolManager().request`
if available) to open the file and read the contents; otherwise, :func:`open`
will be used to open a local file.

Args:

Expand All @@ -299,7 +299,8 @@ def read_text_from_href(self, href: str) -> str:
try:
logger.debug(f"GET {href} Headers: {self.headers}")
if HAS_URLLIB3:
with urllib3.request(
http = urllib3.PoolManager()
with http.request(
"GET",
href,
headers={
Expand Down
2 changes: 1 addition & 1 deletion tests/test_stac_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class ReportingStacIO(DefaultStacIO, DuplicateKeyReportingMixin):
assert str(excinfo.value), f'Found duplicate object name "key" in {src_href}'


@unittest.mock.patch("pystac.stac_io.urllib3.request")
@unittest.mock.patch("pystac.stac_io.urllib3.PoolManager.request")
def test_headers_stac_io(request_mock: unittest.mock.MagicMock) -> None:
stac_io = DefaultStacIO(headers={"Authorization": "api-key fake-api-key-value"})

Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading