mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-12 14:00:01 -04:00
implement redirect and referrer support
This commit is contained in:
parent
8aedbcb6b3
commit
741df8fdcf
3 changed files with 32 additions and 4 deletions
|
@ -56,7 +56,7 @@ function perform_request(url, params, js_data_callback, js_end_callback, body=nu
|
|||
if (body_ptr) _free(body_ptr);
|
||||
_free(url_ptr);
|
||||
|
||||
if (error) console.error("request failed with error code "+error);
|
||||
if (error != 0) console.error("request failed with error code " + error);
|
||||
js_end_callback(error);
|
||||
}
|
||||
|
||||
|
@ -94,6 +94,10 @@ function libcurl_fetch(url, params={}) {
|
|||
}
|
||||
params.body = true;
|
||||
}
|
||||
if (params.referer) {
|
||||
if (!params.headers) params.headers = {};
|
||||
params.headers["Referer"] = params.referer;
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let chunks = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue