8000 Configure larger BufReader for send and receive by rawler · Pull Request #263 · tiny-http/tiny-http · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

< 8000 bdi class="js-issue-title markdown-title">Configure larger BufReader for send and receive #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ use crate::util::RefinedTcpStream;
use crate::util::{SequentialReader, SequentialReaderBuilder, SequentialWriterBuilder};
use crate::Request;

// Tradeoff between memory use, and CPU-overhead of big transfers. Larger values require
// more memory, but can yield faster transfers and less CPU overhead
const BUFFER_SIZE: usize = 32 * 1024;

/// A ClientConnection is an object that will store a socket to a client
/// and return Request objects.
pub struct ClientConnection {
Expand Down Expand Up @@ -55,12 +59,13 @@ impl ClientConnection {
let remote_addr = read_socket.peer_addr();
let secure = read_socket.secure();

let mut source = SequentialReaderBuilder::new(BufReader::with_capacity(1024, read_socket));
let mut source =
SequentialReaderBuilder::new(BufReader::with_capacity(BUFFER_SIZE, read_socket));
let first_header = source.next().unwrap();

ClientConnection {
source,
sink: SequentialWriterBuilder::new(BufWriter::with_capacity(1024, write_socket)),
sink: SequentialWriterBuilder::new(BufWriter::with_capacity(BUFFER_SIZE, write_socket)),
remote_addr,
next_header_source: first_header,
no_more_requests: false,
Expand Down
Loading
0