httpc
httpc copied to clipboard
Response type needs to have a different body type
currently the return type from httpc.send
is Response(String)
https://hexdocs.pm/gleam_httpc/gleam/httpc/#send
This has been causing me runtime errors because I can use httpc to fetch resources like images, e.g. favicons which to not have a string body. I think the correct thing to do is Response(BitString)
I've found the send_bits function. Interesting because I can send a request with type string and get a response with bit_string. and visa versa.
Not sure what the right answer is here.
There's a tension between flexibility and doing what is useful in the majority of cases. For now we can case a string body to a bit string and use send_bits. What do you think?
Hmm. I'm not sure. a dynamic string as the error is not very useful. Problem is sometimes I get a nonstring response from a CDN or proxy on occasion as much as the endpoint is set up to return proper strings
Don't think I have any useful answers,
I'm not sure what you mean by dynamic string? It would be a bit string which could be printed or converted to a string if valid utf8.