Skip to content

Commit

Permalink
Modify the urllib from web cat's branch so that it works with a simpl…
Browse files Browse the repository at this point in the history
…e synchronous xmlhttprequest object.
bnmnetp committed Aug 2, 2013
1 parent 4470bb9 commit 1f350a2
Showing 2 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dist/builtin.js

Large diffs are not rendered by default.

16 changes: 4 additions & 12 deletions src/lib/urllib/request/__init__.js
Original file line number Diff line number Diff line change
@@ -100,19 +100,11 @@ var $builtinmodule = function(name)
* constructs a Response.
*/
request.urlopen = new Sk.builtin.func(function(url, data, timeout) {
return Sk.future(function(continueWith) {
options = {
url: Sk.transformUrl(Sk.ffi.remapToJs(url)),
type: 'GET',
}

if (data) options.data = data;
if (timeout) options.timeout = data.timeout * 1000;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET",url.v,false);
xmlhttp.send(null);

var xhr = $.ajax(options).always(function() {
continueWith(Sk.misceval.callsim(request.Response, xhr));
});
});
return Sk.misceval.callsim(request.Response,xmlhttp)
});


0 comments on commit 1f350a2

Please sign in to comment.