Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
components: rustfmt

- name: cargo test --all
uses: actions-rs/cargo@v1
Expand All @@ -41,6 +42,12 @@ jobs:
cargo update -Z minimal-versions
cargo check

- name: cargo fmt --check
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

MSRV:
runs-on: ubuntu-latest

Expand Down
33 changes: 17 additions & 16 deletions src/common/content_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,23 @@ fn split_in_two(s: &str, separator: char) -> Option<(&str, &str)> {
}

/*
test_header!(test_bytes,
vec![b"bytes 0-499/500"],
Some(ContentRange(ContentRangeSpec::Bytes {
range: Some((0, 499)),
complete_length: Some(500)
})));

test_header!(test_bytes_unknown_len,
vec![b"bytes 0-499/*"],
Some(ContentRange(ContentRangeSpec::Bytes {
range: Some((0, 499)),
complete_length: None
})));

test_header!(test_bytes_unknown_range,
vec![b"bytes */500"],
test_header!(test_bytes,
vec![b"bytes 0-499/500"],
Some(ContentRange(ContentRangeSpec::Bytes {
range: Some((0, 499)),
complete_length: Some(500)
})));

test_header!(test_bytes_unknown_len,
vec![b"bytes 0-499/*"],
Some(ContentRange(ContentRangeSpec::Bytes {
range: Some((0, 499)),
complete_length: None
})));

test_header!(test_bytes_unknown_range,
vec![b"bytes */
500"],
Some(ContentRange(ContentRangeSpec::Bytes {
range: None,
complete_length: Some(500)
Expand Down
4 changes: 1 addition & 3 deletions src/common/etag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ error_type!(InvalidETag);
impl FromStr for ETag {
type Err = InvalidETag;
fn from_str(src: &str) -> Result<Self, Self::Err> {
let val = src
.parse()
.map_err(|_| InvalidETag { _inner: () })?;
let val = src.parse().map_err(|_| InvalidETag { _inner: () })?;

EntityTag::from_owned(val)
.map(ETag)
Expand Down
2 changes: 1 addition & 1 deletion src/common/host.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::fmt;
use std::convert::TryFrom;
use std::fmt;

use http::uri::Authority;

Expand Down
4 changes: 3 additions & 1 deletion src/common/if_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ impl IfRange {
pub fn is_modified(&self, etag: Option<&ETag>, last_modified: Option<&LastModified>) -> bool {
match self.0 {
IfRange_::Date(since) => last_modified.map(|time| since < time.0).unwrap_or(true),
IfRange_::EntityTag(ref entity) => etag.map(|etag| !etag.0.strong_eq(entity)).unwrap_or(true),
IfRange_::EntityTag(ref entity) => {
etag.map(|etag| !etag.0.strong_eq(entity)).unwrap_or(true)
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/origin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::fmt;
use std::convert::TryFrom;
use std::fmt;

use bytes::Bytes;
use http::uri::{self, Authority, Scheme, Uri};
Expand Down
13 changes: 5 additions & 8 deletions src/util/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ impl EntityTag {
}

pub(crate) fn from_val(val: &HeaderValue) -> Option<EntityTag> {
EntityTag::parse(val.as_bytes()).map(|_entity| {
EntityTag(val.clone())
})
EntityTag::parse(val.as_bytes()).map(|_entity| EntityTag(val.clone()))
}
}

Expand Down Expand Up @@ -239,11 +237,10 @@ impl EntityTagRange {
{
match *self {
EntityTagRange::Any => true,
EntityTagRange::Tags(ref tags) => {
tags.iter()
.flat_map(EntityTag::<&str>::parse)
.any(|tag| func(&tag, entity))
},
EntityTagRange::Tags(ref tags) => tags
.iter()
.flat_map(EntityTag::<&str>::parse)
.any(|tag| func(&tag, entity)),
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/util/flat_csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ impl<'a, Sep: Separator> FromIterator<&'a HeaderValue> for FlatCsv<Sep> {
buf.extend_from_slice(val.as_bytes());
}

let val =
HeaderValue::from_maybe_shared(buf.freeze()).expect("comma separated HeaderValues are valid");
let val = HeaderValue::from_maybe_shared(buf.freeze())
.expect("comma separated HeaderValues are valid");

val.into()
}
Expand Down Expand Up @@ -151,8 +151,8 @@ impl<Sep: Separator> FromIterator<HeaderValue> for FlatCsv<Sep> {
buf.extend_from_slice(val.as_bytes());
}

let val =
HeaderValue::from_maybe_shared(buf.freeze()).expect("comma separated HeaderValues are valid");
let val = HeaderValue::from_maybe_shared(buf.freeze())
.expect("comma separated HeaderValues are valid");

val.into()
}
Expand Down