mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[spidermonkey] Set user and password for xhr_open
This commit is contained in:
parent
2b4368aee3
commit
924b494ba6
@ -354,6 +354,38 @@ xhr_open(JSContext *ctx, unsigned int argc, JS::Value *rval)
|
||||
} else {
|
||||
xhr->async = true;
|
||||
}
|
||||
char *username = NULL;
|
||||
char *password = NULL;
|
||||
|
||||
if (argc > 3) {
|
||||
username = jsval_to_string(ctx, args[3]);
|
||||
}
|
||||
if (argc > 4) {
|
||||
password = jsval_to_string(ctx, args[4]);
|
||||
}
|
||||
if (!username && !password) {
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
if (username) {
|
||||
xhr->uri->user = username;
|
||||
xhr->uri->userlen = strlen(username);
|
||||
}
|
||||
if (password) {
|
||||
xhr->uri->password = password;
|
||||
xhr->uri->passwordlen = strlen(password);
|
||||
}
|
||||
char *url2 = get_uri_string(xhr->uri, URI_DIR_LOCATION | URI_PATH | URI_USER | URI_PASSWORD);
|
||||
mem_free_if(username);
|
||||
mem_free_if(password);
|
||||
|
||||
if (!url2) {
|
||||
return false;
|
||||
}
|
||||
done_uri(xhr->uri);
|
||||
xhr->uri = get_uri(url2, URI_DIR_LOCATION | URI_PATH | URI_USER | URI_PASSWORD);
|
||||
mem_free(url2);
|
||||
|
||||
args.rval().setUndefined();
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user