diff --git a/Cargo.lock b/Cargo.lock index 6c2967b..11bf057 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1166,7 +1166,7 @@ dependencies = [ [[package]] name = "rbx_asset" -version = "0.2.1" +version = "0.2.2" dependencies = [ "chrono", "flate2", diff --git a/rbx_asset/Cargo.toml b/rbx_asset/Cargo.toml index 36b4112..a440029 100644 --- a/rbx_asset/Cargo.toml +++ b/rbx_asset/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rbx_asset" -version = "0.2.1" +version = "0.2.2" edition = "2021" publish = ["strafesnet"] diff --git a/rbx_asset/src/cookie.rs b/rbx_asset/src/cookie.rs index 005d36f..b0c8e72 100644 --- a/rbx_asset/src/cookie.rs +++ b/rbx_asset/src/cookie.rs @@ -234,9 +234,9 @@ impl CookieContext{ } } - let resp=self.post(url,body).await.map_err(CreateError::PostError)?; - - Ok(resp.json::().await.map_err(CreateError::Reqwest)?) + Ok(self.post(url,body).await.map_err(CreateError::PostError)? + .error_for_status().map_err(CreateError::Reqwest)? + .json::().await.map_err(CreateError::Reqwest)?) } pub async fn upload(&self,config:UploadRequest,body:impl Into+Clone)->Result{ let mut url=reqwest::Url::parse("https://data.roblox.com/Data/Upload.ashx?json=1&type=Model&genreTypeId=1").map_err(UploadError::ParseError)?; @@ -265,9 +265,9 @@ impl CookieContext{ } } - let resp=self.post(url,body).await.map_err(UploadError::PostError)?; - - Ok(resp.json::().await.map_err(UploadError::Reqwest)?) + Ok(self.post(url,body).await.map_err(UploadError::PostError)? + .error_for_status().map_err(UploadError::Reqwest)? + .json::().await.map_err(UploadError::Reqwest)?) } pub async fn get_asset(&self,config:GetAssetRequest)->Result,GetError>{ let mut url=reqwest::Url::parse("https://assetdelivery.roblox.com/v1/asset/").map_err(GetError::ParseError)?; @@ -279,9 +279,9 @@ impl CookieContext{ query.append_pair("version",version.to_string().as_str()); } } - let resp=self.get(url).await.map_err(GetError::Reqwest)?; - - let body=resp.bytes().await.map_err(GetError::Reqwest)?; + let body=self.get(url).await.map_err(GetError::Reqwest)? + .error_for_status().map_err(GetError::Reqwest)? + .bytes().await.map_err(GetError::Reqwest)?; match maybe_gzip_decode(&mut std::io::Cursor::new(body)){ Ok(ReaderType::GZip(readable))=>read_readable(readable), @@ -303,6 +303,7 @@ impl CookieContext{ } Ok(self.get(url).await.map_err(AssetVersionsPageError::Reqwest)? + .error_for_status().map_err(AssetVersionsPageError::Reqwest)? .json::().await.map_err(AssetVersionsPageError::Reqwest)?) } pub async fn get_inventory_page(&self,config:InventoryPageRequest)->Result{ @@ -316,6 +317,7 @@ impl CookieContext{ } Ok(self.get(url).await.map_err(InventoryPageError::Reqwest)? + .error_for_status().map_err(InventoryPageError::Reqwest)? .json::().await.map_err(InventoryPageError::Reqwest)?) } -} \ No newline at end of file +}