小编nom*_*mad的帖子

如何在 Rust Hyper 中将响应正文读取为字符串?

这个问题有几个答案(这里这里这里),但没有一个对我有用:(

到目前为止我尝试过的:


    use hyper as http;
    use futures::TryStreamExt;

    fn test_heartbeat() {
        let mut runtime = tokio::runtime::Runtime::new().expect("Could not get default runtime");

        runtime.spawn(httpserve());

        let addr = "http://localhost:3030".parse().unwrap();
        let expected = json::to_string(&HeartBeat::default()).unwrap();

        let client = http::Client::new();
        let actual = runtime.block_on(client.get(addr));

        assert!(actual.is_ok());

        if let Ok(response) = actual {
            let (_, body) = response.into_parts();
            
            // what shall be done here? 
        }
    }
Run Code Online (Sandbox Code Playgroud)

我不确定,在这里做什么?

asynchronous rust hyper

5
推荐指数
2
解决办法
8431
查看次数

标签 统计

asynchronous ×1

hyper ×1

rust ×1