Use reqwest async and use futures::executor
This commit is contained in:
@@ -81,7 +81,7 @@ ctrlc = { version = "3.2.2", optional = true }
|
|||||||
rustyline = { version = "12.0.0", optional = true }
|
rustyline = { version = "12.0.0", optional = true }
|
||||||
native-tls = { version = "0.2.4", optional = true }
|
native-tls = { version = "0.2.4", optional = true }
|
||||||
warp = { version = "=0.3.5", features = ["tls"], optional = true }
|
warp = { version = "=0.3.5", features = ["tls"], optional = true }
|
||||||
reqwest = { version = "0.11.18", features = ["blocking"], optional = true }
|
reqwest = { version = "0.11.18", optional = true }
|
||||||
tokio = { version = "1.28.2", features = ["full"] }
|
tokio = { version = "1.28.2", features = ["full"] }
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
|
|||||||
@@ -4288,18 +4288,18 @@ impl Machine {
|
|||||||
let address_string = address_sink.as_str(); //to_string();
|
let address_string = address_sink.as_str(); //to_string();
|
||||||
let address: Url = address_string.parse().unwrap();
|
let address: Url = address_string.parse().unwrap();
|
||||||
|
|
||||||
let client = reqwest::blocking::Client::builder().build().unwrap();
|
let client = reqwest::Client::builder().build().unwrap();
|
||||||
|
|
||||||
// request
|
// request
|
||||||
let mut req = reqwest::blocking::Request::new(method, address);
|
let mut req = reqwest::Request::new(method, address);
|
||||||
|
|
||||||
*req.headers_mut() = headers;
|
*req.headers_mut() = headers;
|
||||||
if !bytes.is_empty() {
|
if !bytes.is_empty() {
|
||||||
*req.body_mut() = Some(reqwest::blocking::Body::from(bytes));
|
*req.body_mut() = Some(reqwest::Body::from(bytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
// do it!
|
// do it!
|
||||||
match client.execute(req) {
|
match futures::executor::block_on(client.execute(req)) {
|
||||||
Ok(resp) => {
|
Ok(resp) => {
|
||||||
// status code
|
// status code
|
||||||
let status = resp.status().as_u16();
|
let status = resp.status().as_u16();
|
||||||
@@ -4336,7 +4336,7 @@ impl Machine {
|
|||||||
self.machine_st.registers[6]
|
self.machine_st.registers[6]
|
||||||
);
|
);
|
||||||
// body
|
// body
|
||||||
let reader = resp.bytes().unwrap().reader();
|
let reader = futures::executor::block_on(resp.bytes()).unwrap().reader();
|
||||||
|
|
||||||
let mut stream = Stream::from_http_stream(
|
let mut stream = Stream::from_http_stream(
|
||||||
AtomTable::build_with(&self.machine_st.atom_tbl, &address_string),
|
AtomTable::build_with(&self.machine_st.atom_tbl, &address_string),
|
||||||
|
|||||||
Reference in New Issue
Block a user