mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 13:47:19 +08:00
Provide httpx default context for OS-provided certs (#11505)
Co-authored-by: Pierrick Hymbert <pierrick.hymbert@gmail.com>
This commit is contained in:
@@ -14,6 +14,7 @@ from openhands.integrations.service_types import (
|
||||
ResourceNotFoundError,
|
||||
User,
|
||||
)
|
||||
from openhands.utils.http_session import httpx_verify_option
|
||||
|
||||
|
||||
class BitBucketMixinBase(BaseGitService, HTTPClient):
|
||||
@@ -83,7 +84,7 @@ class BitBucketMixinBase(BaseGitService, HTTPClient):
|
||||
|
||||
"""
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
async with httpx.AsyncClient(verify=httpx_verify_option()) as client:
|
||||
bitbucket_headers = await self._get_headers()
|
||||
response = await self.execute_request(
|
||||
client, url, bitbucket_headers, params, method
|
||||
|
||||
@@ -11,6 +11,7 @@ from openhands.integrations.service_types import (
|
||||
UnknownException,
|
||||
User,
|
||||
)
|
||||
from openhands.utils.http_session import httpx_verify_option
|
||||
|
||||
|
||||
class GitHubMixinBase(BaseGitService, HTTPClient):
|
||||
@@ -43,7 +44,7 @@ class GitHubMixinBase(BaseGitService, HTTPClient):
|
||||
method: RequestMethod = RequestMethod.GET,
|
||||
) -> tuple[Any, dict]: # type: ignore[override]
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
async with httpx.AsyncClient(verify=httpx_verify_option()) as client:
|
||||
github_headers = await self._get_headers()
|
||||
|
||||
# Make initial request
|
||||
@@ -83,7 +84,7 @@ class GitHubMixinBase(BaseGitService, HTTPClient):
|
||||
self, query: str, variables: dict[str, Any]
|
||||
) -> dict[str, Any]:
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
async with httpx.AsyncClient(verify=httpx_verify_option()) as client:
|
||||
github_headers = await self._get_headers()
|
||||
|
||||
response = await client.post(
|
||||
|
||||
@@ -10,6 +10,7 @@ from openhands.integrations.service_types import (
|
||||
UnknownException,
|
||||
User,
|
||||
)
|
||||
from openhands.utils.http_session import httpx_verify_option
|
||||
|
||||
|
||||
class GitLabMixinBase(BaseGitService, HTTPClient):
|
||||
@@ -41,7 +42,7 @@ class GitLabMixinBase(BaseGitService, HTTPClient):
|
||||
method: RequestMethod = RequestMethod.GET,
|
||||
) -> tuple[Any, dict]: # type: ignore[override]
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
async with httpx.AsyncClient(verify=httpx_verify_option()) as client:
|
||||
gitlab_headers = await self._get_headers()
|
||||
|
||||
# Make initial request
|
||||
@@ -99,7 +100,7 @@ class GitLabMixinBase(BaseGitService, HTTPClient):
|
||||
if variables is None:
|
||||
variables = {}
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
async with httpx.AsyncClient(verify=httpx_verify_option()) as client:
|
||||
gitlab_headers = await self._get_headers()
|
||||
# Add content type header for GraphQL
|
||||
gitlab_headers['Content-Type'] = 'application/json'
|
||||
|
||||
@@ -36,6 +36,7 @@ from openhands.integrations.service_types import (
|
||||
)
|
||||
from openhands.microagent.types import MicroagentContentResponse, MicroagentResponse
|
||||
from openhands.server.types import AppMode
|
||||
from openhands.utils.http_session import httpx_verify_option
|
||||
|
||||
|
||||
class ProviderToken(BaseModel):
|
||||
@@ -174,7 +175,7 @@ class ProviderHandler:
|
||||
) -> SecretStr | None:
|
||||
"""Get latest token from service"""
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
async with httpx.AsyncClient(verify=httpx_verify_option()) as client:
|
||||
resp = await client.get(
|
||||
self.REFRESH_TOKEN_URL,
|
||||
headers={
|
||||
|
||||
Reference in New Issue
Block a user