Compare commits
No commits in common. "81c9669e178cec9f78d29c258ab5f3cdbc8eb774" and "08113e45fb2472050ee2643bcb166112377fa230" have entirely different histories.
81c9669e17
...
08113e45fb
24
src/main.rs
24
src/main.rs
|
@ -181,16 +181,14 @@ async fn git_proto(payload : web::Payload, web::Path((owner, reponame)): web::Pa
|
|||
.push(value.to_string());
|
||||
}
|
||||
|
||||
println!("headers : {:?}", headers);
|
||||
|
||||
let status_code : u16 = {
|
||||
let line = headers.remove("Status").unwrap_or_default();
|
||||
println!("{:?}", &line);
|
||||
// println!("{:?}", &line);
|
||||
let line = line.into_iter().next().unwrap_or_default();
|
||||
let parts : Vec<&str> = line.split(' ').collect();
|
||||
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) {
|
||||
Ok(v) => {Ok(v)}
|
||||
|
@ -206,23 +204,15 @@ async fn git_proto(payload : web::Payload, web::Path((owner, reponame)): web::Pa
|
|||
println!("Write body...");
|
||||
//let mut body = Vec::new();
|
||||
//rdr.bytes()
|
||||
let response = builder.streaming(stream::repeat_with(move || {
|
||||
let response = builder.streaming(stream::repeat_with(|| {
|
||||
let mut buff : [u8; 1024] = [0; 1024];
|
||||
match rdr.read(&mut buff[..]) {
|
||||
Ok(l) => {
|
||||
print!("{}", String::from_utf8_lossy(&buff[0..l]));
|
||||
Ok(Bytes::copy_from_slice(&buff[0..l])) }
|
||||
Ok(l) => {Ok(Bytes::copy_from_slice(&buff[0..l]))}
|
||||
Err(e) => {Err(e)}
|
||||
}
|
||||
})
|
||||
.take_while(|bytes| {
|
||||
match bytes {
|
||||
Ok(bytes) => {future::ready(bytes.len() != 0)}
|
||||
Err(_) => {future::ready(false)}
|
||||
}
|
||||
// future::ready(bytes.is_ok())
|
||||
})
|
||||
);
|
||||
}).take_while(|bytes| {
|
||||
future::ready(bytes.is_ok())
|
||||
}));
|
||||
//rdr.read_to_end(&mut body)?;
|
||||
// println!("{}", String::from_utf8(body.clone()).expect("bad utf8"));
|
||||
return Ok(response);
|
||||
|
|
Loading…
Reference in New Issue