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