mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
fix(bot): reset content-type header before reading content
Discord CDN sometimes returns content-type headers that not only break json deserializing, but also just reading the body...
This commit is contained in:
parent
8f3fa62ec3
commit
f6fceffc3f
1 changed files with 3 additions and 3 deletions
|
|
@ -45,6 +45,9 @@ public class ImportExport
|
|||
try
|
||||
{
|
||||
var response = await _client.GetAsync(url);
|
||||
// hacky fix for discord api returning nonsense charsets sometimes
|
||||
response.Content.Headers.Remove("content-type");
|
||||
response.Content.Headers.Add("content-type", "application/json; charset=UTF-8");
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
if (content == "This content is no longer available.")
|
||||
{
|
||||
|
|
@ -54,9 +57,6 @@ public class ImportExport
|
|||
}
|
||||
if (!response.IsSuccessStatusCode)
|
||||
throw Errors.InvalidImportFile;
|
||||
// hacky fix for discord api returning nonsense charsets sometimes
|
||||
response.Content.Headers.Remove("content-type");
|
||||
response.Content.Headers.Add("content-type", "application/json; charset=UTF-8");
|
||||
data = JsonConvert.DeserializeObject<JObject>(
|
||||
content,
|
||||
_settings
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue