|
1 |
| -""" |
2 |
| - var platformSpecific = { }; |
3 |
| - if (typeof module !== "undefined" && module.require && !(typeof process !== "undefined" && process.versions["electron"])) { |
4 |
| - // We are on node.js |
5 |
| - platformSpecific.newXHR = function () { |
6 |
| - var XHR = module.require("xhr2"); |
7 |
| - return new XHR(); |
8 |
| - }; |
9 |
| -
|
10 |
| - platformSpecific.fixupUrl = function (url, xhr) { |
11 |
| - if (xhr.nodejsBaseUrl === null) { |
12 |
| - var urllib = module.require("url"); |
13 |
| - var u = urllib.parse(url); |
14 |
| - u.protocol = u.protocol || "http:"; |
15 |
| - u.hostname = u.hostname || "localhost"; |
16 |
| - return urllib.format(u); |
17 |
| - } else { |
18 |
| - return url || "/"; |
19 |
| - } |
20 |
| - }; |
21 |
| -
|
22 |
| - platformSpecific.getResponse = function (xhr) { |
23 |
| - return xhr.response; |
24 |
| - }; |
25 |
| - } else { |
26 |
| - // We are in the browser |
27 |
| - platformSpecific.newXHR = function () { |
28 |
| - return new XMLHttpRequest(); |
29 |
| - }; |
30 |
| -
|
31 |
| - platformSpecific.fixupUrl = function (url) { |
32 |
| - return url || "/"; |
33 |
| - }; |
34 |
| -
|
35 |
| - platformSpecific.getResponse = function (xhr) { |
36 |
| - return xhr.response; |
37 |
| - }; |
38 |
| - } |
39 |
| -""" |
40 | 1 | import http.client
|
41 | 2 | from urllib.parse import urlparse
|
42 | 3 | from base64 import b64encode
|
@@ -75,15 +36,13 @@ def _toThreading():
|
75 | 36 | headers=headers,
|
76 | 37 | )
|
77 | 38 | r1 = conn.getresponse()
|
78 |
| - print("LOOK HERE") |
79 |
| - callback( |
80 |
| - { |
81 |
| - "status": r1.status, |
82 |
| - "statusText": r1.reason, |
83 |
| - "headers": tuple([mkHeader(k)(v) for k, v in r1.getheaders]), |
84 |
| - "body": r1.read().decode("utf-8"), |
85 |
| - } |
86 |
| - ) |
| 39 | + output = { |
| 40 | + "status": r1.status, |
| 41 | + "statusText": r1.reason, |
| 42 | + "headers": tuple([mkHeader(k)(v) for k, v in r1.getheaders()]), |
| 43 | + "body": r1.read().decode("utf-8"), |
| 44 | + } |
| 45 | + callback(output) |
87 | 46 |
|
88 | 47 | except Exception as e:
|
89 | 48 | errback(e)
|
|
0 commit comments