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

Response type needs to have a different body type #16

Open
CrowdHailer opened this issue Dec 16, 2020 · 4 comments
Open

Response type needs to have a different body type #16

CrowdHailer opened this issue Dec 16, 2020 · 4 comments

Comments

@CrowdHailer
Copy link
Contributor

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)

@CrowdHailer
Copy link
Contributor Author

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.

@lpil
Copy link
Member

lpil commented Dec 16, 2020

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?

@CrowdHailer
Copy link
Contributor Author

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,

@lpil
Copy link
Member

lpil commented Dec 17, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants