webdriver: Merge pull request #62 from jugglinmike/response-headers
authorMike Pennisi <mike@mikepennisi.com>
Tue, 24 Jan 2017 21:02:40 +0000
changeset 428108 ca3c87720711f46465221b070ca61c2c77f7708f
parent 428107 f31039d0a731dad2f62b7c42cede7a91dc1ebdd3
child 428109 6d7c8369a841962d5ef7dac85f8c7950f5f83bf0
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: Merge pull request #62 from jugglinmike/response-headers Correct response headers Source-Repo: https://github.com/mozilla/webdriver-rust Source-Revision: 91059d95763afdb06dc5219515ddcf4f6a5e0dfd
testing/webdriver/src/server.rs
--- a/testing/webdriver/src/server.rs
+++ b/testing/webdriver/src/server.rs
@@ -1,16 +1,17 @@
 use std::io::Read;
 use std::marker::PhantomData;
 use std::net::SocketAddr;
 use std::sync::mpsc::{channel, Receiver, Sender};
 use std::sync::Mutex;
 use std::thread;
 
-use hyper::header::ContentType;
+use hyper::header::{ContentType, CacheControl, CacheDirective};
+use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value};
 use hyper::method::Method;
 use hyper::Result;
 use hyper::server::{Handler, Listening, Request, Response, Server};
 use hyper::status::StatusCode;
 use hyper::uri::RequestUri::AbsolutePath;
 
 use command::{WebDriverMessage, WebDriverCommand};
 use error::{WebDriverResult, WebDriverError, ErrorStatus};
@@ -218,17 +219,20 @@ impl <U: WebDriverExtensionRoute> Handle
                     }
                 };
                 debug!("Returning status {:?}", status);
                 debug!("Returning body {}", resp_body);
                 {
                     let resp_status = res.status_mut();
                     *resp_status = status;
                 }
-                res.headers_mut().set(ContentType::json());
+                res.headers_mut().set(
+                    ContentType(Mime(TopLevel::Application, SubLevel::Json,
+                                     vec![(Attr::Charset, Value::Utf8)])));
+                res.headers_mut().set(CacheControl(vec![CacheDirective::NoCache]));
                 res.send(&resp_body.as_bytes()).unwrap();
             },
             _ => {}
         }
     }
 }
 
 pub fn start<T, U>(address: SocketAddr,