Compare commits

...

3 Commits

Author SHA1 Message Date
Hubert 81c9669e17 fonctionne mais pose question (stop lorsque 0 et pourquoi pas d'envoie avant la fin) 2021-07-09 07:05:18 +02:00
Hubert 3aa2c63346 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	src/main.rs
2021-07-09 05:59:08 +02:00
Hubert 04b8b43343 try debug 2021-07-08 08:48:04 +02:00
1 changed files with 17 additions and 7 deletions

View File

@ -181,14 +181,16 @@ async fn git_proto(payload : web::Payload, web::Path((owner, reponame)): web::Pa
.push(value.to_string()); .push(value.to_string());
} }
println!("headers : {:?}", headers);
let status_code : u16 = { let status_code : u16 = {
let line = headers.remove("Status").unwrap_or_default(); let line = headers.remove("Status").unwrap_or_default();
// println!("{:?}", &line); println!("{:?}", &line);
let line = line.into_iter().next().unwrap_or_default(); let line = line.into_iter().next().unwrap_or_default();
let parts : Vec<&str> = line.split(' ').collect(); let parts : Vec<&str> = line.split(' ').collect();
parts.into_iter().next().unwrap_or("").parse().unwrap_or(200) parts.into_iter().next().unwrap_or("").parse().unwrap_or(200)
}; };
// println!("{}", status_code); println!("status code {}", status_code);
let statusCode = match StatusCode::from_u16(status_code) { let statusCode = match StatusCode::from_u16(status_code) {
Ok(v) => {Ok(v)} Ok(v) => {Ok(v)}
@ -204,15 +206,23 @@ async fn git_proto(payload : web::Payload, web::Path((owner, reponame)): web::Pa
println!("Write body..."); println!("Write body...");
//let mut body = Vec::new(); //let mut body = Vec::new();
//rdr.bytes() //rdr.bytes()
let response = builder.streaming(stream::repeat_with(|| { let response = builder.streaming(stream::repeat_with(move || {
let mut buff : [u8; 1024] = [0; 1024]; let mut buff : [u8; 1024] = [0; 1024];
match rdr.read(&mut buff[..]) { match rdr.read(&mut buff[..]) {
Ok(l) => {Ok(Bytes::copy_from_slice(&buff[0..l]))} Ok(l) => {
print!("{}", String::from_utf8_lossy(&buff[0..l]));
Ok(Bytes::copy_from_slice(&buff[0..l])) }
Err(e) => {Err(e)} Err(e) => {Err(e)}
} }
}).take_while(|bytes| { })
future::ready(bytes.is_ok()) .take_while(|bytes| {
})); match bytes {
Ok(bytes) => {future::ready(bytes.len() != 0)}
Err(_) => {future::ready(false)}
}
// future::ready(bytes.is_ok())
})
);
//rdr.read_to_end(&mut body)?; //rdr.read_to_end(&mut body)?;
// println!("{}", String::from_utf8(body.clone()).expect("bad utf8")); // println!("{}", String::from_utf8(body.clone()).expect("bad utf8"));
return Ok(response); return Ok(response);