From a4f4cb303370fca4d2def5616814d89a15d71463 Mon Sep 17 00:00:00 2001 From: Hubert Date: Tue, 13 Jul 2021 18:35:29 +0200 Subject: [PATCH] compile but runtime fails with "failt to parse header value" --- src/main.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index a6b5aea..c3f7f25 100644 --- a/src/main.rs +++ b/src/main.rs @@ -149,7 +149,7 @@ async fn git_main(web::Path((owner, reponame)): web::Path<(String, String)>, web GitMainTemplate { repo, browse : browse, root : path, user_opt : Some(user)} } //#[get("/git/{owner}/{repo}.git/{path:.*}")] -async fn git_proto(payload : web::Payload, web::Path((owner, reponame)): web::Path<(String, String)>, mut req: HttpRequest) -> io::Result{ +async fn git_proto(mut payload : web::Payload, web::Path((owner, reponame)): web::Path<(String, String)>, mut req: HttpRequest) -> io::Result{ println!("enter git_proto"); let mut cmd = Command::new("git"); cmd.arg("http-backend"); @@ -173,10 +173,10 @@ async fn git_proto(payload : web::Payload, web::Path((owner, reponame)): web::Pa .stdout(Stdio::piped()) .stdin(Stdio::piped()); let mut p: Child = cmd.spawn()?; - //p.stdin.take().unwrap().write() let mut input = p.stdin.take().unwrap(); - let mut writer = Writer(input); - payload.try_for_each(|bytes| writer.write(bytes)).await; // le faire au niveau de payload et pas de input + while let Some(Ok(bytes)) = payload.next().await { + input.write_all(bytes.bytes()).await; + } println!("input sent"); let mut rdr = tokio::io::BufReader::new(p.stdout.take().unwrap()); @@ -184,7 +184,8 @@ async fn git_proto(payload : web::Payload, web::Path((owner, reponame)): web::Pa loop { let mut line = String::new(); let len = rdr.read_line(&mut line).await?; - if line == "" || line == "\r" { + // println!("line : \"{}\"", line); + if line.len() == 2 { break; }