Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't handle charset Windows-1252 in responses #238

Closed
djmitchella opened this issue Sep 20, 2019 · 0 comments · Fixed by #355
Closed

Can't handle charset Windows-1252 in responses #238

djmitchella opened this issue Sep 20, 2019 · 0 comments · Fixed by #355
Labels
bug Something isn't working
Milestone

Comments

@djmitchella
Copy link

If the API I'm talking to has code like

Content = new StringContent(JsonConvert.SerializeObject(response), Encoding.Default, "application/json")

then the charset ends up as Windows-1252, not UTF-8, because Encoding.Default turns out to be Windows-1252 in this situation.

httprepl can't handle this charset, so instead of the body from the server, I get an error from httprepl itself -- in this case I'm getting an error back from the server, and the body is encoded this way:

The headers returned are:

HTTP/1.1 401 Unauthorized
Access-Control-Allow-Origin: *
Cache-Control: private
Content-Length: 41
Content-Type: application/json; charset=Windows-1252
Date: Fri, 20 Sep 2019 19:34:56 GMT

and then the error from httprepl itself is:

System.InvalidOperationException: The character set provided in ContentType is invalid. Cannot read content as string using an invalid character set. ---> System.ArgumentException: 'Windows-1252' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.

In this case, I control the API as well so I can change the encoding there, but it would be nice if httprepl could manage this charset itself.

@tlmii tlmii added the bug Something isn't working label Sep 23, 2019
@bradygaster bradygaster added this to the 3.1 milestone Jun 22, 2020
@tlmii tlmii linked a pull request Jun 26, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants