Skip to content

Commit 7dd0f93

Browse files
committed
Have a fallback for an empty response
This happens in tests.
1 parent 154cc0a commit 7dd0f93

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/crates-io/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ impl Registry {
202202
body.read(buf).unwrap_or(0)
203203
})?;
204204
// Can't derive RustcDecodable because JSON has a key named "crate" :(
205-
let response = Json::from_str(&body)?;
205+
let response = if body.len() > 0 {
206+
Json::from_str(&body)?
207+
} else {
208+
Json::from_str("{}")?
209+
};
206210
let invalid_categories: Vec<String> =
207211
response
208212
.find_path(&["warnings", "invalid_categories"])

0 commit comments

Comments
 (0)