Skip to content

Commit

Permalink
Set Content-Type header when curling webdriver (#2261)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlapa committed Sep 5, 2020
1 parent 7ef5591 commit 48680ca
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::shell::Shell;
use anyhow::{bail, format_err, Context, Error};
use curl::easy::Easy;
use curl::easy::{Easy, List};
use log::{debug, warn};
use rouille::url::Url;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -522,6 +522,9 @@ impl Client {
match method {
Method::Post(data) => {
self.handle.post(true)?;
self.handle.http_headers(build_headers(
&["Content-Type: application/json"]
))?;
self.handle.post_fields_copy(data.as_bytes())?;
}
Method::Delete => self.handle.custom_request("DELETE")?,
Expand Down Expand Up @@ -561,6 +564,14 @@ impl Drop for Client {
}
}

fn build_headers(headers: &[&str]) -> List {
let mut list = List::new();
for header in headers {
list.append(header).unwrap();
}
list
}

fn read<R: Read>(r: &mut R) -> io::Result<Vec<u8>> {
let mut dst = Vec::new();
r.read_to_end(&mut dst)?;
Expand Down

0 comments on commit 48680ca

Please sign in to comment.