webdriver: Send JSON header with response.
authorJames Graham <james@hoppipolla.co.uk>
Thu, 13 Aug 2015 00:07:53 +0100
changeset 428038 249f480b65b3ef2c2c01e1d1a58bd5b1172ba95e
parent 428037 b1f9d7ee40c87bed7b7c61c1a9c572059384ea08
child 428039 95cedfcaef6e614e0d65f05b16c55cea8ee9129d
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
webdriver: Send JSON header with response. Source-Repo: https://github.com/mozilla/webdriver-rust Source-Revision: 5008a3d04e30a1080f747f271febb04b19ee824c
testing/webdriver/Cargo.toml
testing/webdriver/src/server.rs
--- a/testing/webdriver/Cargo.toml
+++ b/testing/webdriver/Cargo.toml
@@ -1,12 +1,12 @@
 [package]
 
 name = "webdriver"
-version = "0.2.2"
+version = "0.2.3"
 authors = ["Mozilla Tools and Automation <auto-tools@mozilla.com>"]
 description = "Library implementing the wire protocol for the W3C WebDriver specification."
 repository = "https://github.com/jgraham/webdriver-rust"
 license = "MPL-2.0"
 
 [dependencies]
 log = "0.3.1"
 regex = "0.1.41"
--- a/testing/webdriver/src/server.rs
+++ b/testing/webdriver/src/server.rs
@@ -1,15 +1,15 @@
 use std::io::{Write, Read};
 use std::sync::Mutex;
 use std::sync::mpsc::{channel, Receiver, Sender};
 use std::thread;
 use std::net::SocketAddr;
 
-use hyper::header::ContentLength;
+use hyper::header::{ContentLength, ContentType};
 use hyper::method::Method;
 use hyper::server::{Server, Handler, Request, Response};
 use hyper::uri::RequestUri::AbsolutePath;
 use hyper::status::StatusCode;
 
 use command::{WebDriverMessage, WebDriverCommand};
 use error::{WebDriverResult, WebDriverError, ErrorStatus};
 use httpapi::WebDriverHttpApi;
@@ -212,16 +212,17 @@ impl Handler for HttpHandler {
                 };
                 error!("Returning status {:?}", status);
                 error!("Returning body {}", resp_body);
                 {
                     let resp_status = res.status_mut();
                     *resp_status = status;
                 }
                 res.headers_mut().set(ContentLength(resp_body.len() as u64));
+                res.headers_mut().set(ContentType::json());
                 let mut stream = res.start().unwrap();
                 stream.write_all(&resp_body.as_bytes()).unwrap();
                 stream.end().unwrap();
             },
             _ => {}
         }
     }
 }