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

More permissive BinaryEncoding #945

Open
zakmagnus opened this issue Aug 7, 2020 · 0 comments
Open

More permissive BinaryEncoding #945

zakmagnus opened this issue Aug 7, 2020 · 0 comments

Comments

@zakmagnus
Copy link

What happened?

I tried to use dialogue to communicate with a service that serves arbitrary files. My application logic then parses the file contents. InputStream seems like the perfect type for the result of this call, and ConjureBodySerDe.binaryInputStreamDeserializer provides just that, so that's what I tried to use. However, the service I'm trying to talk to responds with different content type headers depending on the file that it's serving. However, the BinaryEncoding that this deserializer uses only works with application/octet-stream, so it may refuse to deserialize the response.

What did you want to happen?

Fundamentally, Encoding has a getContentType(), so the idea that an encoding is for a specific content type is baked into the design here. But, anything can be treated as an input stream, even if the content could also be interpreted as a more specific type. I would like it if BinaryEncoding could somehow support this, allowing deserialization of any response as an InputStream regardless of the reported content type. It seems easy enough to just have BinaryEncoding.supportsContentType() always return true, but again, there is no accurate answer to BinaryEncoding.getContentType(), so I don't know how that can be implemented. I think part of the issue here is that encodings seem to refer to both serialization and deserialization, but arbitrary binary serialization is not supported (BinaryEncoding.serializer() throws). That makes sense in my opinion, and it makes sense that serialization requires declaring a content type, but since serialization is not possible here, the need for a specific content type makes this encoding too rigid to be useful for my situation.

BLAB: How can the encoding system be refactored to allow turning anything into an input stream? At minimum, it seems like the system needs to be more flexible about there being exactly one content type.

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

1 participant