Skip to content

Commit

Permalink
Refactor headers update code
Browse files Browse the repository at this point in the history
  • Loading branch information
seriaati committed Jun 7, 2024
1 parent 13bd94d commit fbc630a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions genshin/client/components/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,9 @@ async def _request_hook(
params = {k: v for k, v in params.items() if k != "authkey"}
url = url.update_query(params)

headers_ = dict(headers or {})
if self.device_id:
headers_["x-rpc-device_id"] = self.device_id
if self.device_fp:
headers_["x-rpc-device_fp"] = self.device_fp
headers.update(headers_)
headers.update(
{k: v for k, v in {"x-rpc-device_id": self.device_id, "x-rpc-device_fp": self.device_fp}.items() if v}
)

if data:
self.logger.debug("%s %s\n%s", method, url, json.dumps(data, separators=(",", ":")))
Expand Down

0 comments on commit fbc630a

Please sign in to comment.