mirror of
https://github.com/rust-lang/cargo
synced 2024-10-13 03:02:45 +00:00
Have a fallback for an empty response
This happens in tests.
This commit is contained in:
parent
154cc0aa54
commit
7dd0f932a8
|
@ -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"])
|
||||
|
|
Loading…
Reference in a new issue