matteocontrini/PlainHttp

Feature request: Response Body Bytes

developervariety opened this issue · 2 comments

Instead of having a response in only one format, a byte array would be appreciated.

If I would've looked a bit further, .Message has everything I needed haha.

Hi, that's correct, the HttpResponse exposes the System.Net.Http.HttpResponseMessage, and from that you should be able to access the response content.

Note that the body will still be read to a string unless you set ReadBody to false in the request. In that case, however, you would need to read the body manually:

byte[] array = await resp.Message.Content.ReadAsByteArrayAsync();

There's definitely space for improvement, but honestly I didn't think much about it since the most common use case is probably to read the response as a string :)