This commit is contained in:
Hubert 2021-07-08 14:26:34 +02:00
parent ee1efbe8aa
commit 7d8bfbbb62
1 changed files with 11 additions and 2 deletions

View File

@ -23,8 +23,8 @@ 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;
#[derive(Template)]
@ -201,7 +201,16 @@ async fn git_proto(payload : web::Payload, web::Path((owner, reponame)): web::Pa
}
}
println!("Write body...");
let mut body = Vec::new();
//rdr.bytes()
let mut buff : [u8; 1024] = [0; 1024];
builder.streaming(stream::repeat_with(|| {
match rdr.read(&buff) {
Ok(l) => {Bytes::copy_from_slice(&buff[0..l])}
Err(_) => {}
}
}));
rdr.read_to_end(&mut body)?;
// println!("{}", String::from_utf8(body.clone()).expect("bad utf8"));
return Ok(builder.body(body));