|
@@ -5,7 +5,7 @@ use std::io::Read;
|
|
use hyper::{Get, Post};
|
|
use hyper::{Get, Post};
|
|
use hyper::Client;
|
|
use hyper::Client;
|
|
use hyper::client;
|
|
use hyper::client;
|
|
-use hyper::header::{ContentType, ETag, EntityTag, IfNoneMatch, Headers};
|
|
|
|
|
|
+use hyper::header::{ContentType, ETag, EntityTag, IfNoneMatch, Headers, TransferEncoding};
|
|
use hyper::server::{Handler, Request, Response};
|
|
use hyper::server::{Handler, Request, Response};
|
|
use hyper::status::StatusCode::{InternalServerError, NotFound, NotModified, Unauthorized};
|
|
use hyper::status::StatusCode::{InternalServerError, NotFound, NotModified, Unauthorized};
|
|
use hyper::uri::RequestUri::AbsolutePath;
|
|
use hyper::uri::RequestUri::AbsolutePath;
|
|
@@ -34,6 +34,7 @@ impl SiteHandler {
|
|
fn post(&self, body: &str) -> client::Response {
|
|
fn post(&self, body: &str) -> client::Response {
|
|
let mut headers = Headers::new();
|
|
let mut headers = Headers::new();
|
|
headers.set(ContentType::form_url_encoded());
|
|
headers.set(ContentType::form_url_encoded());
|
|
|
|
+ headers.remove::<TransferEncoding>();
|
|
self.client
|
|
self.client
|
|
.post(API_ENDPOINT)
|
|
.post(API_ENDPOINT)
|
|
.headers(headers)
|
|
.headers(headers)
|
|
@@ -130,6 +131,7 @@ impl Handler for SiteHandler {
|
|
});
|
|
});
|
|
|
|
|
|
res.headers_mut().extend(proxy_res.headers.iter());
|
|
res.headers_mut().extend(proxy_res.headers.iter());
|
|
|
|
+ res.headers_mut().remove::<TransferEncoding>();
|
|
|
|
|
|
let json = json::encode(&body).unwrap();
|
|
let json = json::encode(&body).unwrap();
|
|
res.send(json.as_bytes()).unwrap();
|
|
res.send(json.as_bytes()).unwrap();
|
|
@@ -145,6 +147,7 @@ impl Handler for SiteHandler {
|
|
let form_data = form_urlencoded::serialize(¶ms);
|
|
let form_data = form_urlencoded::serialize(¶ms);
|
|
let mut proxy_res = self.post(&form_data);
|
|
let mut proxy_res = self.post(&form_data);
|
|
res.headers_mut().extend(proxy_res.headers.iter());
|
|
res.headers_mut().extend(proxy_res.headers.iter());
|
|
|
|
+ res.headers_mut().remove::<TransferEncoding>();
|
|
let mut res = res.start().unwrap();
|
|
let mut res = res.start().unwrap();
|
|
io::copy(&mut proxy_res, &mut res).ok().expect("Failed to proxy");
|
|
io::copy(&mut proxy_res, &mut res).ok().expect("Failed to proxy");
|
|
res.end().unwrap();
|
|
res.end().unwrap();
|