1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-11-29 21:11:17 +00:00

Fix long client urls #129

This commit is contained in:
Nikolay Kim 2018-03-22 07:44:16 -07:00
parent 1107fdec9d
commit b942bcc4a6
3 changed files with 28 additions and 16 deletions

View file

@ -2,6 +2,8 @@
## 0.4.11 ## 0.4.11
* Fix long client urls #129
* Fix client connection pooling * Fix client connection pooling
* Use more ergonomic `actix_web::Error` instead of `http::Error` for `HttpResponseBuilder::body()` * Use more ergonomic `actix_web::Error` instead of `http::Error` for `HttpResponseBuilder::body()`

View file

@ -98,26 +98,26 @@ impl HttpClientWriter {
self.flags.insert(Flags::STARTED); self.flags.insert(Flags::STARTED);
self.encoder = content_encoder(self.buffer.clone(), msg); self.encoder = content_encoder(self.buffer.clone(), msg);
// render message
{
let mut buffer = self.buffer.get_mut();
if let Body::Binary(ref bytes) = *msg.body() {
buffer.reserve(256 + msg.headers().len() * AVERAGE_HEADER_SIZE + bytes.len());
} else {
buffer.reserve(256 + msg.headers().len() * AVERAGE_HEADER_SIZE);
}
if msg.upgrade() { if msg.upgrade() {
self.flags.insert(Flags::UPGRADE); self.flags.insert(Flags::UPGRADE);
} }
// render message
{
// status line // status line
let _ = write!(buffer, "{} {} {:?}\r\n", write!(self.buffer, "{} {} {:?}\r\n",
msg.method(), msg.method(),
msg.uri().path_and_query().map(|u| u.as_str()).unwrap_or("/"), msg.uri().path_and_query().map(|u| u.as_str()).unwrap_or("/"),
msg.version()); msg.version())?;
// write headers // write headers
let mut buffer = self.buffer.get_mut();
if let Body::Binary(ref bytes) = *msg.body() {
buffer.reserve(msg.headers().len() * AVERAGE_HEADER_SIZE + bytes.len());
} else {
buffer.reserve(msg.headers().len() * AVERAGE_HEADER_SIZE);
}
for (key, value) in msg.headers() { for (key, value) in msg.headers() {
let v = value.as_ref(); let v = value.as_ref();
let k = key.as_str().as_bytes(); let k = key.as_str().as_bytes();

View file

@ -1,4 +1,4 @@
use std::mem; use std::{io, mem};
use std::cell::RefCell; use std::cell::RefCell;
use std::rc::Rc; use std::rc::Rc;
use std::collections::VecDeque; use std::collections::VecDeque;
@ -138,3 +138,13 @@ impl Clone for SharedBytes {
SharedBytes(self.0.clone(), self.1.clone()) SharedBytes(self.0.clone(), self.1.clone())
} }
} }
impl io::Write for SharedBytes {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.extend_from_slice(buf);
Ok(buf.len())
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}