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: 3 additions & 4 deletions src/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ impl Handler for Middleware {

// Second, if we're requesting html, then we've only got one page so
// serve up that page. Otherwise proxy on to the rest of the app.
let wants_html = {
let content = req.headers().find("Accept").unwrap_or(Vec::new());
content.iter().any(|s| s.contains("html"))
};
let wants_html = req.headers().find("Accept").map(|accept| {
accept.iter().any(|s| s.contains("html"))
}).unwrap_or(true); // If no Accept header is specified, serve up html.
if wants_html {
self.dist.call(&mut RequestProxy {
other: req,
Expand Down
5 changes: 3 additions & 2 deletions src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ impl<'a> RequestUtils for Request + 'a {
}

fn wants_json(&self) -> bool {
let content = self.headers().find("Accept").unwrap_or(Vec::new());
content.iter().any(|s| s.contains("json"))
self.headers().find("Accept").map(|accept| {
accept.iter().any(|s| s.contains("json"))
}).unwrap_or(false)
}

fn pagination(&self, default: usize, max: usize) -> CargoResult<(i64, i64)> {
Expand Down