mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-25 09:59:21 +02:00
travis config
This commit is contained in:
@ -36,6 +36,7 @@ pub enum ContentEncoding {
|
||||
|
||||
impl ContentEncoding {
|
||||
|
||||
#[inline]
|
||||
fn is_compression(&self) -> bool {
|
||||
match *self {
|
||||
ContentEncoding::Identity | ContentEncoding::Auto => false,
|
||||
@ -51,7 +52,7 @@ impl ContentEncoding {
|
||||
ContentEncoding::Identity | ContentEncoding::Auto => "identity",
|
||||
}
|
||||
}
|
||||
// default quality
|
||||
/// default quality value
|
||||
fn quality(&self) -> f64 {
|
||||
match *self {
|
||||
ContentEncoding::Br => 1.1,
|
||||
@ -62,6 +63,7 @@ impl ContentEncoding {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: remove memory allocation
|
||||
impl<'a> From<&'a str> for ContentEncoding {
|
||||
fn from(s: &'a str) -> ContentEncoding {
|
||||
match s.trim().to_lowercase().as_ref() {
|
||||
@ -157,11 +159,7 @@ impl EncodedPayload {
|
||||
Box::new(GzDecoder::new(BytesMut::with_capacity(8192).writer()))),
|
||||
_ => Decoder::Identity,
|
||||
};
|
||||
EncodedPayload {
|
||||
inner: inner,
|
||||
decoder: dec,
|
||||
error: false,
|
||||
}
|
||||
EncodedPayload{ inner: inner, decoder: dec, error: false }
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,6 +252,7 @@ impl PayloadWriter for EncodedPayload {
|
||||
}
|
||||
return
|
||||
}
|
||||
trace!("Error decoding gzip encoding");
|
||||
}
|
||||
|
||||
Decoder::Deflate(ref mut decoder) => {
|
||||
@ -417,8 +416,7 @@ impl PayloadEncoder {
|
||||
ContentEncoding::Br => ContentEncoder::Br(
|
||||
BrotliEncoder::new(transfer, 5)),
|
||||
ContentEncoding::Identity => ContentEncoder::Identity(transfer),
|
||||
ContentEncoding::Auto =>
|
||||
unreachable!()
|
||||
ContentEncoding::Auto => unreachable!()
|
||||
}
|
||||
)
|
||||
}
|
||||
@ -643,10 +641,8 @@ impl TransferEncoding {
|
||||
pub fn is_eof(&self) -> bool {
|
||||
match self.kind {
|
||||
TransferEncodingKind::Eof => true,
|
||||
TransferEncodingKind::Chunked(ref eof) =>
|
||||
*eof,
|
||||
TransferEncodingKind::Length(ref remaining) =>
|
||||
*remaining == 0,
|
||||
TransferEncodingKind::Chunked(ref eof) => *eof,
|
||||
TransferEncodingKind::Length(ref remaining) => *remaining == 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,61 +70,73 @@ impl Payload {
|
||||
}
|
||||
|
||||
/// Indicates EOF of payload
|
||||
#[inline]
|
||||
pub fn eof(&self) -> bool {
|
||||
self.inner.borrow().eof()
|
||||
}
|
||||
|
||||
/// Length of the data in this payload
|
||||
#[inline]
|
||||
pub fn len(&self) -> usize {
|
||||
self.inner.borrow().len()
|
||||
}
|
||||
|
||||
/// Is payload empty
|
||||
#[inline]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.inner.borrow().len() == 0
|
||||
}
|
||||
|
||||
/// Get first available chunk of data.
|
||||
#[inline]
|
||||
pub fn readany(&self) -> ReadAny {
|
||||
ReadAny(Rc::clone(&self.inner))
|
||||
}
|
||||
|
||||
/// Get exact number of bytes
|
||||
#[inline]
|
||||
pub fn readexactly(&self, size: usize) -> ReadExactly {
|
||||
ReadExactly(Rc::clone(&self.inner), size)
|
||||
}
|
||||
|
||||
/// Read until `\n`
|
||||
#[inline]
|
||||
pub fn readline(&self) -> ReadLine {
|
||||
ReadLine(Rc::clone(&self.inner))
|
||||
}
|
||||
|
||||
/// Read until match line
|
||||
#[inline]
|
||||
pub fn readuntil(&self, line: &[u8]) -> ReadUntil {
|
||||
ReadUntil(Rc::clone(&self.inner), line.to_vec())
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[inline]
|
||||
pub fn readall(&self) -> Option<Bytes> {
|
||||
self.inner.borrow_mut().readall()
|
||||
}
|
||||
|
||||
/// Put unused data back to payload
|
||||
#[inline]
|
||||
pub fn unread_data(&mut self, data: Bytes) {
|
||||
self.inner.borrow_mut().unread_data(data);
|
||||
}
|
||||
|
||||
/// Get size of payload buffer
|
||||
#[inline]
|
||||
pub fn buffer_size(&self) -> usize {
|
||||
self.inner.borrow().buffer_size()
|
||||
}
|
||||
|
||||
/// Set size of payload buffer
|
||||
#[inline]
|
||||
pub fn set_buffer_size(&self, size: usize) {
|
||||
self.inner.borrow_mut().set_buffer_size(size)
|
||||
}
|
||||
|
||||
/// Convert payload into compatible `HttpResponse` body stream
|
||||
#[inline]
|
||||
pub fn stream(self) -> BodyStream {
|
||||
Box::new(self.map(|i| i.0).map_err(|e| e.into()))
|
||||
}
|
||||
@ -134,6 +146,7 @@ impl Stream for Payload {
|
||||
type Item = PayloadItem;
|
||||
type Error = PayloadError;
|
||||
|
||||
#[inline]
|
||||
fn poll(&mut self) -> Poll<Option<PayloadItem>, PayloadError> {
|
||||
self.inner.borrow_mut().readany()
|
||||
}
|
||||
|
Reference in New Issue
Block a user