Set Content-Type header when curling webdriver
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};
@@ -522,6 +522,8 @@ 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")?,
@@ -561,6 +563,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)?;
