Try to read request body

[?]
Dec 18, 2018, 7:37 PM
UCY2DO3DQ2WE55CVVJYMHINBWCZYPCSZ5Q2EHMZNNZIU5LPCJNSAC

Dependencies

  • [2] MOXHYSQ3 Use more common error type\n\nMove to failure::Error after https://github.com/rust-lang-nursery/failure/pull/283 landed.
  • [3] X6L47BHQ Use different structure for established xmpp connection
  • [4] EOHEZXX3 Move request processing to structure
  • [*] FVVPKFTL Initial commit

Change contents

  • replacement in src/main.rs at line 27
    [3.4066][3.53:89]()
    use tokio::prelude::{Future, Sink};
    [3.4066]
    [3.4092]
    use tokio::prelude::{Future, Sink, Stream};
  • replacement in src/main.rs at line 45
    [3.266][2.0:59](),[2.59][3.303:398](),[3.303][3.303:398]()
    type Error = Box<dyn std::error::Error + Sync + Send>;
    type Future = Box<dyn Future<Item = Response<Self::ResBody>, Error = Self::Error> + Send>;
    [3.266]
    [3.398]
    type Error = Box<dyn std::error::Error + Sync + Send + 'static>;
    type Future = Box<dyn Future<Item = Response<Self::ResBody>, Error = Self::Error> + Send + 'static>;
  • replacement in src/main.rs at line 66
    [2.143][2.143:238](),[2.238][3.1241:1303](),[3.1241][3.1241:1303]()
    .map_err(|e| Box::new(e) as Box<dyn std::error::Error + Sync + Send>),
    )) as Box<Future<Item = _, Error = _> + Send>
    [2.143]
    [3.1303]
    .map_err(|e| Box::new(e) as Box<dyn std::error::Error + Sync + Send + 'static>),
    )) as Box<Future<Item = _, Error = _> + Send + 'static>
  • replacement in src/main.rs at line 70
    [3.1346][3.1346:1384](),[3.1346][3.1346:1384]()
    info!("Got request");
    [3.1346]
    [3.1384]
    info!("Got request. Reading body...");
  • replacement in src/main.rs at line 72
    [3.1410][3.1410:2213](),[3.1410][3.1410:2213]()
    self.cmd_send
    .clone()
    .send(XmppCommand { xmpp_to })
    .then(|r| match r {
    Ok(_) => {
    tokio::prelude::future::ok(Response::new(Body::from("Accepted")))
    }
    Err(e) => {
    error!("Command sent error: {}", e);
    tokio::prelude::future::result(
    Response::builder()
    .status(hyper::StatusCode::BAD_REQUEST)
    .body(Body::from(format!("Command sent error: {}", e))),
    )
    }
    [3.1410]
    [2.239]
    /*req.into_body()
    .map_err(|e| Box::new(e) as Box<dyn std::error::Error + Sync + Send + 'static>)
    .fold(String::new(), |acc, ch| {
    std::str::from_utf8(&*ch).map(|s| {
    acc.push_str(s);
    acc
    })
  • replacement in src/main.rs at line 80
    [2.266][2.266:361](),[2.361][3.2241:2302](),[3.2241][3.2241:2302]()
    .map_err(|e| Box::new(e) as Box<dyn std::error::Error + Sync + Send>),
    ) as Box<Future<Item = _, Error = _> + Send>
    [2.266]
    [3.2302]
    .and_then(|msg: String| {*/
    self.cmd_send
    .clone()
    .send(XmppCommand { xmpp_to })
    .then(|r| match r {
    Ok(_) => tokio::prelude::future::ok(Response::new(Body::from(
    "Accepted",
    ))),
    Err(e) => {
    error!("Command sent error: {}", e);
    tokio::prelude::future::result(
    Response::builder()
    .status(hyper::StatusCode::BAD_REQUEST)
    .body(Body::from(format!(
    "Command sent error: {}",
    e
    ))),
    )
    }
    })
    .map_err(|e| {
    Box::new(e) as Box<dyn std::error::Error + Sync + Send + 'static>
    })
    // }),
    ) as Box<Future<Item = _, Error = _> + Send + 'static>
  • replacement in src/main.rs at line 117
    [3.2532][2.362:421]()
    type Error = Box<dyn std::error::Error + Sync + Send>;
    [3.2532]
    [3.2569]
    type Error = Box<dyn std::error::Error + Sync + Send + 'static>;