Compare commits

..

No commits in common. "81c9669e178cec9f78d29c258ab5f3cdbc8eb774" and "08113e45fb2472050ee2643bcb166112377fa230" have entirely different histories.

1 changed files with 7 additions and 17 deletions

View File

@ -181,16 +181,14 @@ 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 {}", status_code); // println!("{}", 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)}
@ -206,23 +204,15 @@ 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(move || { let response = builder.streaming(stream::repeat_with(|| {
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(l) => {Ok(Bytes::copy_from_slice(&buff[0..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| {
.take_while(|bytes| { future::ready(bytes.is_ok())
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);