Skip to content

Commit 7086a1f

Browse files
author
Mike Solomon
committed
Initial version
1 parent e6ae00d commit 7086a1f

File tree

1 file changed

+7
-48
lines changed

1 file changed

+7
-48
lines changed

python-ffi/Affjax.py

Lines changed: 7 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,3 @@
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-
"""
401
import http.client
412
from urllib.parse import urlparse
423
from base64 import b64encode
@@ -75,15 +36,13 @@ def _toThreading():
7536
headers=headers,
7637
)
7738
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)
8746

8847
except Exception as e:
8948
errback(e)

0 commit comments

Comments
 (0)