mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-13 14:30:02 -04:00
refactor request code
This commit is contained in:
parent
0d7369c77a
commit
1748ca7dd9
12 changed files with 222 additions and 194 deletions
|
@ -22,11 +22,8 @@ class CurlWebSocket {
|
|||
}
|
||||
|
||||
connect() {
|
||||
let response_info;
|
||||
let data_callback = () => {};
|
||||
let headers_callback = (info) => {
|
||||
response_info = info;
|
||||
}
|
||||
let headers_callback = () => {};
|
||||
let finish_callback = (error) => {
|
||||
if (error === 0) {
|
||||
this.connected = true;
|
||||
|
@ -39,7 +36,7 @@ class CurlWebSocket {
|
|||
else {
|
||||
this.cleanup(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
let request_options = {
|
||||
headers: this.options.headers || {}
|
||||
};
|
||||
|
@ -49,7 +46,11 @@ class CurlWebSocket {
|
|||
if (this.options.verbose) {
|
||||
request_options._libcurl_verbose = 1;
|
||||
}
|
||||
this.http_handle = perform_request(this.url, request_options, data_callback, finish_callback, headers_callback, null);
|
||||
|
||||
this.http_handle = create_handle(this.url, data_callback, finish_callback, headers_callback);
|
||||
c_func(_http_set_options, [this.http_handle, JSON.stringify(request_options), null, 0]);
|
||||
_websocket_set_options(this.http_handle);
|
||||
start_request(this.http_handle);
|
||||
}
|
||||
|
||||
recv() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue