softprops / hyperlocal

🔌 ✨rustlang hyper bindings for local unix domain sockets
MIT License
227 stars 46 forks source link

Body is dropped #51

Closed changweige closed 2 years ago

changweige commented 2 years ago

Hi, I am trying to use this hyperlocal to send http api to my http server in below method:

    pub async fn put(&self, path: &str, data: Option<String>) -> Result<()> {
        let client = Client::unix();
        let uri = Uri::new(&self.sock_path, path);
        let (body, _) = if let Some(d) = data {
            let l = d.len();
            (d.into(), l)
        } else {
            (Body::empty(), 0)
        };

        let req = Request::builder()
            .method(Method::PUT)
            .uri(uri)
            .body(body)
            .unwrap();

        client.request(req).await.unwrap();

But my http user gets no body from the request. Do we have examples on how to PUT/POST http request with body? Or did I do something wrong in above code snippet?

changweige commented 2 years ago

Sorry for the noise I made.