Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main.rs
This commit is contained in:
Hubert 2021-07-09 05:59:08 +02:00
commit 3aa2c63346
1 changed files with 17 additions and 10 deletions

View File

@ -23,10 +23,9 @@ use actix_web::http::{header, StatusCode};
use std::io;
use std::collections::HashMap;
use std::io::{Read, BufRead, Write, ErrorKind};
use futures::{StreamExt, TryStreamExt, future};
use actix_web::web::Buf;
use futures::{StreamExt, TryStreamExt, future, stream};
use actix_web::web::{Buf, Bytes};
use actix_web::http::header::IntoHeaderValue;
use futures::stream;
#[derive(Template)]
#[template(path = "hello.html")]
@ -204,13 +203,21 @@ async fn git_proto(payload : web::Payload, web::Path((owner, reponame)): web::Pa
}
}
println!("headers written");
let mut body = Vec::new();
rdr.read_to_end(&mut body)?;
println!("{}", String::from_utf8(body.clone()).expect("bad utf8"));
// builder.streaming(stream::repeat_with(rdr.rea))
return Ok(builder.body(body));
println!("Write body...");
//let mut body = Vec::new();
//rdr.bytes()
let response = builder.streaming(stream::repeat_with(|| {
let mut buff : [u8; 1024] = [0; 1024];
match rdr.read(&mut buff[..]) {
Ok(l) => {Ok(Bytes::copy_from_slice(&buff[0..l]))}
Err(e) => {Err(e)}
}
}).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);
}