Skip to content

Commit

Permalink
Merge pull request #23 from oxy-nr/feature/add-sdk-identifier
Browse files Browse the repository at this point in the history
Add a SDK version identifier to all requests
  • Loading branch information
oxy-zy authored Sep 3, 2024
2 parents a915179 + a9be26b commit 45f3182
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/oxylabs/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.6"
__version__ = "1.0.7"
4 changes: 4 additions & 0 deletions src/oxylabs/internal/internal.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import asyncio
import base64
import logging
from platform import python_version, architecture

import aiohttp
import requests

from oxylabs.sources.ecommerce.ecommerce import Ecommerce, EcommerceAsync
from oxylabs.sources.serp.serp import SERP, SERPAsync
from oxylabs.utils.defaults import ASYNC_BASE_URL, SYNC_BASE_URL
from oxylabs._version import __version__

# Configure logging
logging.basicConfig(level=logging.INFO)
Expand Down Expand Up @@ -39,9 +41,11 @@ class BaseClient:
def __init__(self, base_url: str, api_credentials: APICredentials) -> None:
self._base_url = base_url
self._api_credentials = api_credentials
bits, _ = architecture()
self._headers = {
"Content-Type": "application/json",
"Authorization": f"Basic {self._api_credentials.get_encoded_credentials()}",
"x-oxylabs-sdk": f"oxylabs-sdk-python/{__version__} ({python_version()}; {bits})",
}


Expand Down
5 changes: 5 additions & 0 deletions src/oxylabs/proxy/proxy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from platform import python_version, architecture
from typing import Optional
from urllib.parse import quote, urlparse

Expand All @@ -10,6 +11,7 @@
PROXY_PORT,
)
from oxylabs.utils.utils import prepare_config
from oxylabs._version import __version__

# Configure logging
logging.basicConfig(level=logging.INFO)
Expand All @@ -35,6 +37,9 @@ def __init__(self, username: str, password: str) -> None:
}
self._session.verify = False
self._url_to_scrape = None
bits, _ = architecture()
self._session.headers["x-oxylabs-sdk"] = f"oxylabs-sdk-python/{__version__} ({python_version()}; {bits})"


def _build_proxy_url(self) -> str:
"""
Expand Down

0 comments on commit 45f3182

Please sign in to comment.