KeyisBClient-mmbp 0.0.0.1.13__py3-none-any.whl → 0.0.0.1.15__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ import os
8
8
  import sys
9
9
  import httpx
10
10
  from KeyisBLogging import logging
11
- from KeyisBClient import Exceptions
11
+ from KeyisBClient import Exceptions, Url
12
12
  from KeyisBClient.models import Request, Response
13
13
 
14
14
  def resource_path(relative_path):
@@ -46,6 +46,8 @@ class Client:
46
46
  logging.debug("No DNS record found")
47
47
  raise Exceptions.DNS.InvalidDNSError()
48
48
 
49
+ request_url = Url(str(request.url))
50
+
49
51
  request.url.hostname = request.dnsObject.host() # type: ignore
50
52
  request.url.scheme = request.dnsObject.protocolInfo()['connection_protocol']
51
53
 
@@ -69,6 +71,13 @@ class Client:
69
71
  json = response.json()
70
72
  except:
71
73
  json = None
74
+
75
+ response_url = Url(str(response.url))
76
+ if response_url.hostname == request.dnsObject.host():
77
+ response_url.hostname = request_url.hostname
78
+ if response_url.hostname == request.dnsObject.protocolInfo()['connection_protocol']:
79
+ response_url.scheme = request_url.scheme
80
+
72
81
  return Response(
73
82
  status_code=response.status_code,
74
83
  headers=response.headers,
@@ -79,13 +88,16 @@ class Client:
79
88
  request=request,
80
89
  extensions=response.extensions,
81
90
  history=None,
82
- default_encoding=response.encoding or "utf-8"
91
+ default_encoding=response.encoding or "utf-8",
92
+ url=response_url
83
93
  )
84
94
  except httpx.TimeoutException:
85
95
  logging.debug("HTTPS request timed out")
86
96
  raise Exceptions.ServerTimeoutError()
87
- except httpx.ConnectError:
97
+ except httpx.ConnectError as e:
88
98
  logging.debug("Failed to connect to server")
99
+ if '[SSL: CERTIFICATE_VERIFY_FAILED]' in str(e):
100
+ raise Exceptions.CertificateVerifyFailed()
89
101
  raise Exceptions.ErrorConnection()
90
102
  except httpx.HTTPStatusError as e:
91
103
  logging.debug(f"HTTP error occurred: {e.response.status_code} - {e.response.text}")
@@ -99,6 +111,8 @@ class Client:
99
111
  logging.debug("No DNS record found")
100
112
  raise Exceptions.DNS.InvalidDNSError()
101
113
 
114
+ request_url = Url(str(request.url))
115
+
102
116
  request.url.hostname = request.dnsObject.host() # type: ignore
103
117
  request.url.scheme = request.dnsObject.protocolInfo()['connection_protocol']
104
118
 
@@ -123,6 +137,14 @@ class Client:
123
137
  json = response.json()
124
138
  except:
125
139
  json = None
140
+
141
+
142
+ response_url = Url(str(response.url))
143
+ if response_url.hostname == request.dnsObject.host():
144
+ response_url.hostname = request_url.hostname
145
+ if response_url.hostname == request.dnsObject.protocolInfo()['connection_protocol']:
146
+ response_url.scheme = request_url.scheme
147
+
126
148
  return Response(
127
149
  status_code=response.status_code,
128
150
  headers=response.headers,
@@ -133,7 +155,8 @@ class Client:
133
155
  request=request,
134
156
  extensions=response.extensions,
135
157
  history=None,
136
- default_encoding=response.encoding or "utf-8"
158
+ default_encoding=response.encoding or "utf-8",
159
+ url=response_url
137
160
  )
138
161
  except httpx.TimeoutException:
139
162
  logging.debug("HTTPS request timed out")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: KeyisBClient_mmbp
3
- Version: 0.0.0.1.13
3
+ Version: 0.0.0.1.15
4
4
  Summary: KeyisBClient_mmbp
5
5
  Home-page: https://github.com/KeyisB/libs/tree/main/KeyisBClient_mmbp
6
6
  Author: KeyisB
@@ -0,0 +1,9 @@
1
+ KeyisBClient_mmbp/Client.py,sha256=BqIzEQ_RrAltvpq-RyEMnu5cH6_XZ6LBU_Jrx9JnFME,7008
2
+ KeyisBClient_mmbp/__init__.py,sha256=y8gLgE6Z2VvJFPnXGVeO7P_OYRoRZufvurQrR5RG1jg,1562
3
+ KeyisBClient_mmbp/gw_certs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ KeyisBClient_mmbp/gw_certs/v0.0.1.crt,sha256=4SZKPldOi2FXuOl1Lv9JgjojA8-RL2dzn_mh4XVeuZs,1342
5
+ KeyisBClient_mmbp-0.0.0.1.15.dist-info/LICENSE,sha256=WH_t7dKZyWJ5Ld07eYIkUG4Tv6zZWXtAdsUqYAUesn0,1084
6
+ KeyisBClient_mmbp-0.0.0.1.15.dist-info/METADATA,sha256=koL-3NszFzcFMN60ANv7y-ZnKf2KeU4V_BUAYLqEIEA,513
7
+ KeyisBClient_mmbp-0.0.0.1.15.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
8
+ KeyisBClient_mmbp-0.0.0.1.15.dist-info/top_level.txt,sha256=h6s4YlLhQ13xiqaDqhXJamhuez9D23BmPTwQvMr54FA,18
9
+ KeyisBClient_mmbp-0.0.0.1.15.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- KeyisBClient_mmbp/Client.py,sha256=Dp_fyLz_AwR8_vsug9D2KGcVIV-MlQVivmv8XOkb1Vg,5994
2
- KeyisBClient_mmbp/__init__.py,sha256=y8gLgE6Z2VvJFPnXGVeO7P_OYRoRZufvurQrR5RG1jg,1562
3
- KeyisBClient_mmbp/gw_certs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- KeyisBClient_mmbp/gw_certs/v0.0.1.crt,sha256=4SZKPldOi2FXuOl1Lv9JgjojA8-RL2dzn_mh4XVeuZs,1342
5
- KeyisBClient_mmbp-0.0.0.1.13.dist-info/LICENSE,sha256=WH_t7dKZyWJ5Ld07eYIkUG4Tv6zZWXtAdsUqYAUesn0,1084
6
- KeyisBClient_mmbp-0.0.0.1.13.dist-info/METADATA,sha256=hi-vZVIYCSNDtLLZPMv6yZsO5f5BI2kY-N3rlKwHWDY,513
7
- KeyisBClient_mmbp-0.0.0.1.13.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
8
- KeyisBClient_mmbp-0.0.0.1.13.dist-info/top_level.txt,sha256=h6s4YlLhQ13xiqaDqhXJamhuez9D23BmPTwQvMr54FA,18
9
- KeyisBClient_mmbp-0.0.0.1.13.dist-info/RECORD,,