add ClientBuilder.default_headers() for wasm32 target (#1084)

This commit is contained in:
stevelr
2020-11-16 21:09:47 +00:00
committed by GitHub
parent 2dec3b725f
commit 4fe07d81cf
12 changed files with 210 additions and 16 deletions

View File

@@ -1,3 +1,5 @@
#![cfg(not(target_arch = "wasm32"))]
#[cfg(feature = "__tls")]
#[tokio::test]
async fn test_badssl_modern() {

View File

@@ -1,3 +1,4 @@
#![cfg(not(target_arch = "wasm32"))]
mod support;
use futures_util::stream::StreamExt;
use support::*;

View File

@@ -1,3 +1,4 @@
#![cfg(not(target_arch = "wasm32"))]
mod support;
use futures_util::stream::StreamExt;
use support::*;

View File

@@ -1,3 +1,4 @@
#![cfg(not(target_arch = "wasm32"))]
mod support;
use support::*;

View File

@@ -1,3 +1,4 @@
#![cfg(not(target_arch = "wasm32"))]
mod support;
use futures_util::stream::StreamExt;
use support::*;

View File

@@ -1,3 +1,4 @@
#![cfg(not(target_arch = "wasm32"))]
use std::convert::Infallible;
use std::future::Future;
use std::net;

View File

@@ -1,3 +1,4 @@
#![cfg(not(target_arch = "wasm32"))]
mod support;
use support::*;

24
tests/wasm_simple.rs Normal file
View File

@@ -0,0 +1,24 @@
#![cfg(target_arch = "wasm32")]
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen]
extern "C" {
// Use `js_namespace` here to bind `console.log(..)` instead of just
// `log(..)`
#[wasm_bindgen(js_namespace = console)]
fn log(s: &str);
}
#[wasm_bindgen_test]
async fn simple_example() {
let res = reqwest::get("https://hyper.rs")
.await
.expect("http get example");
log(&format!("Status: {}", res.status()));
let body = res.text().await.expect("response to utf-8 text");
log(&format!("Body:\n\n{}", body));
}