Akka HTTP passthru response from Retrofit 2 client

Hi there,

I have an (Java) akka-http based webserver that sometimes has to query another HTTP service.
As there is an existing Retrofit 2 based client implementation for the other webservice I currently consume that webservice with Retrofit and need to pass the result somehow back to some kind of complete directive. The response from that webservice can be rather large and complex (multipart MIME, binary, non-binary) so I would like to stream it unmodified thru akka-http.

Now how would I do that? I can get a java.io.InputStream from the Retrofit response that I could probably convert to a Source with StreamConverters and pass this to a completeWithSource() directive. But what do I pass for Marshalling and EntityStreamingSupport then?
Or would I have to create a ResponseEntity like with HttpEntity.CloseDelimited(…), create a HttpResponse.create().withEntity(…) and pass that to the complete() directive. What works and would would be the best approach?

Because I have no control over clients and because of the network topology I cannot just complete with a redirect() directive.

Thanks,

Felix

Hi Felix,

the best way would indeed be to use a Source from StreamConverters and create an HttpEntity.CloseDelimited or HttpEntity.Chunked and pass that to complete. Or you can also create a full HttpResponse containing that entity if you also want to set other response attributes.

Johannes

Hi Johannes,

that is how I do it right now and it seems to work as expected. Thank you for the clarification.

Felix