Have a fallback for an empty response

This happens in tests.
This commit is contained in:
Carol (Nichols || Goulding) 2016-11-29 16:09:00 -05:00
parent 154cc0aa54
commit 7dd0f932a8

View file

@ -202,7 +202,11 @@ impl Registry {
body.read(buf).unwrap_or(0)
})?;
// Can't derive RustcDecodable because JSON has a key named "crate" :(
let response = Json::from_str(&body)?;
let response = if body.len() > 0 {
Json::from_str(&body)?
} else {
Json::from_str("{}")?
};
let invalid_categories: Vec<String> =
response
.find_path(&["warnings", "invalid_categories"])