Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing #10

Open
ibraheemdev opened this issue Sep 9, 2023 · 1 comment
Open

Testing #10

ibraheemdev opened this issue Sep 9, 2023 · 1 comment

Comments

@ibraheemdev
Copy link
Owner

ibraheemdev commented Sep 9, 2023

Along with the overall lack of integration tests, some of the utilities Body::wrap_stream, BodyReader would benefit from unit tests.

@icp1994
Copy link

icp1994 commented Sep 12, 2023

I hit b38f8ea today while trying to put together a tiny POST server. Here's the extracted repro snippet (fixed in master now), feel free to use it as test if you want:

use std::io::Read;

use astra::{Body, ConnectionInfo, Request, Response, Server};

fn main() {
    Server::bind("localhost:3000")
        .serve(handle)
        .expect("serve failed");
}

fn handle(mut req: Request, _info: ConnectionInfo) -> Response {
    if req.method().as_str() == "POST" {
        let mut resp = String::with_capacity(64);
        _ = req.body_mut().reader().take(64).read_to_string(&mut resp);
        Response::new(Body::new(resp))
    } else {
        Response::new(Body::empty())
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants