Compare commits
3 Commits
08113e45fb
...
81c9669e17
Author | SHA1 | Date |
---|---|---|
Hubert | 81c9669e17 | |
Hubert | 3aa2c63346 | |
Hubert | 04b8b43343 |
24
src/main.rs
24
src/main.rs
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue