sapiadapter 1.2.0__tar.gz → 1.4.0__tar.gz
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.
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
|
|
2
2
|
import requests
|
|
3
3
|
|
|
4
|
-
__version__ = "1.2.0"
|
|
4
|
+
#__version__ = "1.2.0"
|
|
5
5
|
|
|
6
6
|
__all__ = [ "run" , "defdata" , "defmeta" ]
|
|
7
7
|
|
|
8
8
|
DATA = None
|
|
9
9
|
|
|
10
|
+
def check_compression(response):
|
|
11
|
+
encoding = response.headers.get("Content-Encoding", "").lower()
|
|
12
|
+
transfer_encoding = response.headers.get("Transfer-Encoding", "").lower()
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
"content_encoding": encoding or None,
|
|
16
|
+
"transfer_encoding": transfer_encoding or None,
|
|
17
|
+
"is_compressed": encoding in ("gzip", "deflate", "br", "zstd"),
|
|
18
|
+
"content_length_header": response.headers.get("Content-Length"),
|
|
19
|
+
"actual_body_length": len(response.content),
|
|
20
|
+
}
|
|
21
|
+
|
|
10
22
|
def run( url = None , params = None ) :
|
|
11
23
|
|
|
12
24
|
if not url : raise "url params None"
|
|
@@ -27,6 +39,9 @@ def run( url = None , params = None ) :
|
|
|
27
39
|
try : body = response.json( )
|
|
28
40
|
except ValueError : body = response.text
|
|
29
41
|
|
|
42
|
+
#info = check_compression(response)
|
|
43
|
+
#print(info)
|
|
44
|
+
|
|
30
45
|
global DATA
|
|
31
46
|
DATA = body
|
|
32
47
|
|
|
File without changes
|