1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-30 18:34:36 +01:00

travis config

This commit is contained in:
Nikolay Kim 2018-01-10 21:02:28 -08:00
parent 49cdddf479
commit 1a31554ee6
3 changed files with 47 additions and 28 deletions

View File

@ -1,14 +1,27 @@
language: rust language: rust
sudo: false
rust:
- 1.20.0
- stable
- beta
- nightly-2018-01-03
sudo: required
dist: trusty dist: trusty
cache:
cargo: true
apt: true
matrix:
include:
- rust: 1.20.0
- rust: stable
- rust: beta
- rust: nightly
allow_failures:
- rust: nightly
- rust: beta
#rust:
# - 1.20.0
# - stable
# - beta
# - nightly-2018-01-03
env: env:
global: global:
- RUSTFLAGS="-C link-dead-code" - RUSTFLAGS="-C link-dead-code"
@ -42,9 +55,6 @@ script:
cd examples/multipart && cargo check && cd ../.. cd examples/multipart && cargo check && cd ../..
cd examples/json && cargo check && cd ../.. cd examples/json && cargo check && cd ../..
cd examples/template_tera && cargo check && cd ../.. cd examples/template_tera && cargo check && cd ../..
fi
- |
if [[ "$TRAVIS_RUST_VERSION" == "beta" ]]; then
cd examples/diesel && cargo check && cd ../.. cd examples/diesel && cargo check && cd ../..
cd examples/tls && cargo check && cd ../.. cd examples/tls && cargo check && cd ../..
cd examples/websocket-chat && cargo check && cd ../.. cd examples/websocket-chat && cargo check && cd ../..
@ -58,7 +68,7 @@ script:
# Upload docs # Upload docs
after_success: after_success:
- | - |
if [[ "$TRAVIS_OS_NAME" == "linux" && "$TRAVIS_PULL_REQUEST" = "false" && "$TRAVIS_BRANCH" == "master" && "$TRAVIS_RUST_VERSION" == "nightly-2018-01-03" ]]; then if [[ "$TRAVIS_OS_NAME" == "linux" && "$TRAVIS_PULL_REQUEST" = "false" && "$TRAVIS_BRANCH" == "master" && "$TRAVIS_RUST_VERSION" == "nightly" ]]; then
cargo doc --features alpn --no-deps && cargo doc --features alpn --no-deps &&
echo "<meta http-equiv=refresh content=0;url=os_balloon/index.html>" > target/doc/index.html && echo "<meta http-equiv=refresh content=0;url=os_balloon/index.html>" > target/doc/index.html &&
cargo install mdbook && cargo install mdbook &&

View File

@ -36,6 +36,7 @@ pub enum ContentEncoding {
impl ContentEncoding { impl ContentEncoding {
#[inline]
fn is_compression(&self) -> bool { fn is_compression(&self) -> bool {
match *self { match *self {
ContentEncoding::Identity | ContentEncoding::Auto => false, ContentEncoding::Identity | ContentEncoding::Auto => false,
@ -51,7 +52,7 @@ impl ContentEncoding {
ContentEncoding::Identity | ContentEncoding::Auto => "identity", ContentEncoding::Identity | ContentEncoding::Auto => "identity",
} }
} }
// default quality /// default quality value
fn quality(&self) -> f64 { fn quality(&self) -> f64 {
match *self { match *self {
ContentEncoding::Br => 1.1, ContentEncoding::Br => 1.1,
@ -62,6 +63,7 @@ impl ContentEncoding {
} }
} }
// TODO: remove memory allocation
impl<'a> From<&'a str> for ContentEncoding { impl<'a> From<&'a str> for ContentEncoding {
fn from(s: &'a str) -> ContentEncoding { fn from(s: &'a str) -> ContentEncoding {
match s.trim().to_lowercase().as_ref() { match s.trim().to_lowercase().as_ref() {
@ -157,11 +159,7 @@ impl EncodedPayload {
Box::new(GzDecoder::new(BytesMut::with_capacity(8192).writer()))), Box::new(GzDecoder::new(BytesMut::with_capacity(8192).writer()))),
_ => Decoder::Identity, _ => Decoder::Identity,
}; };
EncodedPayload { EncodedPayload{ inner: inner, decoder: dec, error: false }
inner: inner,
decoder: dec,
error: false,
}
} }
} }
@ -254,6 +252,7 @@ impl PayloadWriter for EncodedPayload {
} }
return return
} }
trace!("Error decoding gzip encoding");
} }
Decoder::Deflate(ref mut decoder) => { Decoder::Deflate(ref mut decoder) => {
@ -417,8 +416,7 @@ impl PayloadEncoder {
ContentEncoding::Br => ContentEncoder::Br( ContentEncoding::Br => ContentEncoder::Br(
BrotliEncoder::new(transfer, 5)), BrotliEncoder::new(transfer, 5)),
ContentEncoding::Identity => ContentEncoder::Identity(transfer), ContentEncoding::Identity => ContentEncoder::Identity(transfer),
ContentEncoding::Auto => ContentEncoding::Auto => unreachable!()
unreachable!()
} }
) )
} }
@ -643,10 +641,8 @@ impl TransferEncoding {
pub fn is_eof(&self) -> bool { pub fn is_eof(&self) -> bool {
match self.kind { match self.kind {
TransferEncodingKind::Eof => true, TransferEncodingKind::Eof => true,
TransferEncodingKind::Chunked(ref eof) => TransferEncodingKind::Chunked(ref eof) => *eof,
*eof, TransferEncodingKind::Length(ref remaining) => *remaining == 0,
TransferEncodingKind::Length(ref remaining) =>
*remaining == 0,
} }
} }

View File

@ -70,61 +70,73 @@ impl Payload {
} }
/// Indicates EOF of payload /// Indicates EOF of payload
#[inline]
pub fn eof(&self) -> bool { pub fn eof(&self) -> bool {
self.inner.borrow().eof() self.inner.borrow().eof()
} }
/// Length of the data in this payload /// Length of the data in this payload
#[inline]
pub fn len(&self) -> usize { pub fn len(&self) -> usize {
self.inner.borrow().len() self.inner.borrow().len()
} }
/// Is payload empty /// Is payload empty
#[inline]
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.inner.borrow().len() == 0 self.inner.borrow().len() == 0
} }
/// Get first available chunk of data. /// Get first available chunk of data.
#[inline]
pub fn readany(&self) -> ReadAny { pub fn readany(&self) -> ReadAny {
ReadAny(Rc::clone(&self.inner)) ReadAny(Rc::clone(&self.inner))
} }
/// Get exact number of bytes /// Get exact number of bytes
#[inline]
pub fn readexactly(&self, size: usize) -> ReadExactly { pub fn readexactly(&self, size: usize) -> ReadExactly {
ReadExactly(Rc::clone(&self.inner), size) ReadExactly(Rc::clone(&self.inner), size)
} }
/// Read until `\n` /// Read until `\n`
#[inline]
pub fn readline(&self) -> ReadLine { pub fn readline(&self) -> ReadLine {
ReadLine(Rc::clone(&self.inner)) ReadLine(Rc::clone(&self.inner))
} }
/// Read until match line /// Read until match line
#[inline]
pub fn readuntil(&self, line: &[u8]) -> ReadUntil { pub fn readuntil(&self, line: &[u8]) -> ReadUntil {
ReadUntil(Rc::clone(&self.inner), line.to_vec()) ReadUntil(Rc::clone(&self.inner), line.to_vec())
} }
#[doc(hidden)] #[doc(hidden)]
#[inline]
pub fn readall(&self) -> Option<Bytes> { pub fn readall(&self) -> Option<Bytes> {
self.inner.borrow_mut().readall() self.inner.borrow_mut().readall()
} }
/// Put unused data back to payload /// Put unused data back to payload
#[inline]
pub fn unread_data(&mut self, data: Bytes) { pub fn unread_data(&mut self, data: Bytes) {
self.inner.borrow_mut().unread_data(data); self.inner.borrow_mut().unread_data(data);
} }
/// Get size of payload buffer /// Get size of payload buffer
#[inline]
pub fn buffer_size(&self) -> usize { pub fn buffer_size(&self) -> usize {
self.inner.borrow().buffer_size() self.inner.borrow().buffer_size()
} }
/// Set size of payload buffer /// Set size of payload buffer
#[inline]
pub fn set_buffer_size(&self, size: usize) { pub fn set_buffer_size(&self, size: usize) {
self.inner.borrow_mut().set_buffer_size(size) self.inner.borrow_mut().set_buffer_size(size)
} }
/// Convert payload into compatible `HttpResponse` body stream /// Convert payload into compatible `HttpResponse` body stream
#[inline]
pub fn stream(self) -> BodyStream { pub fn stream(self) -> BodyStream {
Box::new(self.map(|i| i.0).map_err(|e| e.into())) Box::new(self.map(|i| i.0).map_err(|e| e.into()))
} }
@ -134,6 +146,7 @@ impl Stream for Payload {
type Item = PayloadItem; type Item = PayloadItem;
type Error = PayloadError; type Error = PayloadError;
#[inline]
fn poll(&mut self) -> Poll<Option<PayloadItem>, PayloadError> { fn poll(&mut self) -> Poll<Option<PayloadItem>, PayloadError> {
self.inner.borrow_mut().readany() self.inner.borrow_mut().readany()
} }