Skip to content

Commit

Permalink
Update user-agent value passed by the library
Browse files Browse the repository at this point in the history
This fixes #38.
  • Loading branch information
lpellegr committed Jun 13, 2024
1 parent 0092942 commit 1123a2f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 0 additions & 2 deletions ipregistry/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
name = "ipregistry"

from .version import __version__

from .cache import *
from .core import *
from .json import *
Expand Down
12 changes: 9 additions & 3 deletions ipregistry/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import importlib
import json
import sys
import urllib.parse
Expand All @@ -22,7 +22,6 @@

import requests

from .__init__ import __version__
from .model import (ApiError, ApiResponse, ApiResponseCredits, ApiResponseThrottling, AutonomousSystem,
ClientError, IpInfo, LookupError, RequesterAutonomousSystem, RequesterIpInfo,
RequesterUserAgent, UserAgent)
Expand Down Expand Up @@ -248,8 +247,15 @@ def __create_api_error(response):
raise ClientError("HTTP Error occurred, but no response was received.")

def __headers(self):
python_version = sys.version.split()[0]
lib_version = importlib.metadata.version('ipregistry')
return {
"authorization": "ApiKey " + self._config.api_key,
"content-type": "application/json",
"user-agent": "Ipregistry/Python" + str(sys.version_info[0]) + "/" + __version__
"user-agent":
"Ipregistry/" +
lib_version +
" (Library; Python/" +
python_version +
"; +https://github.com/ipregistry/ipregistry-python)"
}
1 change: 0 additions & 1 deletion ipregistry/version.py

This file was deleted.

0 comments on commit 1123a2f

Please sign in to comment.