compile but runtime fails with "failt to parse header value"

This commit is contained in:
Hubert 2021-07-13 18:35:29 +02:00
parent f007c47dbb
commit a4f4cb3033
1 changed files with 6 additions and 5 deletions

View File

@ -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)} GitMainTemplate { repo, browse : browse, root : path, user_opt : Some(user)}
} }
//#[get("/git/{owner}/{repo}.git/{path:.*}")] //#[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<HttpResponse>{ async fn git_proto(mut payload : web::Payload, web::Path((owner, reponame)): web::Path<(String, String)>, mut req: HttpRequest) -> io::Result<HttpResponse>{
println!("enter git_proto"); println!("enter git_proto");
let mut cmd = Command::new("git"); let mut cmd = Command::new("git");
cmd.arg("http-backend"); cmd.arg("http-backend");
@ -173,10 +173,10 @@ async fn git_proto(payload : web::Payload, web::Path((owner, reponame)): web::Pa
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.stdin(Stdio::piped()); .stdin(Stdio::piped());
let mut p: Child = cmd.spawn()?; let mut p: Child = cmd.spawn()?;
//p.stdin.take().unwrap().write()
let mut input = p.stdin.take().unwrap(); let mut input = p.stdin.take().unwrap();
let mut writer = Writer(input); while let Some(Ok(bytes)) = payload.next().await {
payload.try_for_each(|bytes| writer.write(bytes)).await; // le faire au niveau de payload et pas de input input.write_all(bytes.bytes()).await;
}
println!("input sent"); println!("input sent");
let mut rdr = tokio::io::BufReader::new(p.stdout.take().unwrap()); 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 { loop {
let mut line = String::new(); let mut line = String::new();
let len = rdr.read_line(&mut line).await?; let len = rdr.read_line(&mut line).await?;
if line == "" || line == "\r" { // println!("line : \"{}\"", line);
if line.len() == 2 {
break; break;
} }