From 7d8bfbbb62ac034472381e4d4be32ee9ee336206 Mon Sep 17 00:00:00 2001 From: Hubert Date: Thu, 8 Jul 2021 14:26:34 +0200 Subject: [PATCH] save --- src/main.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 16b2a33..d928de1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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));