In akka-http, HttpRequest
and HttpResponse
are mostly immutable objects, except for their HttpEntity
bodies (which have a Source
).
Is it safe to send a request, response, or solo entity to another actor (especially a remote actor) or is some precaution needed?
As stated in the comments: sending an
HttpEntity
to a remoteActor
is unlikely to work due to the socket limitation. Further evidence can be found in the documentation (emphasis theirs):However, the
ByteString
values coming from theSource
do not have the same limitations as the Source itself since ByteString is immutable. You could simply drain the Source on the localakka-http
ActorSystem and dispatchByteString
values to your remote Actor.As an example, say you want to use an Actor to uppercase all of the characters in a utf-8 based HttpEntity. You can setup your Actor:
Then your akka-http could look like: