From c4b4f13fa6f5970e95d6e0ea813c65c2a6683616 Mon Sep 17 00:00:00 2001 From: asonix Date: Fri, 10 Jul 2020 17:47:41 -0500 Subject: [PATCH] Don't validate content type on response, pleromo is weird --- src/jobs/instance.rs | 4 ++-- src/requests.rs | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/jobs/instance.rs b/src/jobs/instance.rs index 25a5491..5f7c3a2 100644 --- a/src/jobs/instance.rs +++ b/src/jobs/instance.rs @@ -41,7 +41,7 @@ impl QueryInstance { .await?; let description = if instance.description.is_empty() { - instance.short_description + instance.short_description.unwrap_or(String::new()) } else { instance.description }; @@ -102,7 +102,7 @@ impl ActixJob for QueryInstance { #[derive(serde::Deserialize)] struct Instance { title: String, - short_description: String, + short_description: Option, description: String, version: String, registrations: bool, diff --git a/src/requests.rs b/src/requests.rs index 24eabd3..86a2e3c 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -110,9 +110,12 @@ impl Requests { return Err(MyError::Status(res.status())); } - res.json() + let body = res + .body() .await - .map_err(|e| MyError::ReceiveResponse(url.to_string(), e.to_string())) + .map_err(|e| MyError::ReceiveResponse(url.to_string(), e.to_string()))?; + + Ok(serde_json::from_slice(body.as_ref())?) } pub async fn fetch_bytes(&self, url: &str) -> Result<(String, Bytes), MyError> {