Skip to content

Allow requests to respect the environment #669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2024
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Use [uv](https://github.com/astral-sh/uv) for CI [#663](https://github.com/stac-utils/pystac-client/pull/663)
- use `APILayoutStrategy` as fallback strategy [#666](https://github.com/stac-utils/pystac-client/pull/666)

### Fixed

- Respect the `REQUESTS_CA_BUNDLE` and `CURL_CA_BUNDLE` environment variables when sending requests [#669](https://github.com/stac-utils/pystac-client/pull/669)

## [v0.7.6]

### Fixed
Expand Down
5 changes: 4 additions & 1 deletion pystac_client/stac_api_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ def request(
if self.timeout is not None:
msg += f" Timeout: {self.timeout}"
logger.debug(msg)
resp = self.session.send(prepped, timeout=self.timeout)
send_kwargs = self.session.merge_environment_settings(
prepped.url, proxies={}, stream=None, verify=True, cert=None
)
resp = self.session.send(prepped, timeout=self.timeout, **send_kwargs)
except Exception as err:
logger.debug(err)
raise APIError(str(err))
Expand Down
8 changes: 8 additions & 0 deletions tests/test_stac_api_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from urllib.parse import parse_qs, urlsplit

import pytest
from pytest import MonkeyPatch
from requests_mock.mocker import Mocker

from pystac_client.exceptions import APIError
Expand Down Expand Up @@ -266,3 +267,10 @@ def test_timeout_smoke_test(self) -> None:
stac_api_io = StacApiIO(timeout=42)
response = stac_api_io.read_text(STAC_URLS["PLANETARY-COMPUTER"])
assert isinstance(response, str)

@pytest.mark.parametrize("name", ("REQUESTS_CA_BUNDLE", "CURL_CA_BUNDLE"))
def test_respect_env_for_certs(self, monkeypatch: MonkeyPatch, name: str) -> None:
monkeypatch.setenv(name, "/not/a/real/file")
stac_api_io = StacApiIO()
with pytest.raises(APIError):
stac_api_io.request("https://earth-search.aws.element84.com/v1/")
Loading