Getting Uri out of HttpResponse

Hello,

Is there a way in Akka HTTP to retrieve original Uri out of HttpResponse (Akka Client)? I haven’t seen anything particularly interesting inside headers nor as class field.

Thanks.

Hi @bottaio,

no, the URI is only present in the request. When you use Http.singleRequest you can keep the URI of the request with the response with something like this:

def runRequest(request: HttpRequest): Future[(Uri, HttpResponse)] =
  Http().singleRequest(request).map(response => (request.uri, response))

Now the returned future will contain both the original URI and the response together in a tuple.

Hope that helps,
Johannes

1 Like

Thanks, this is the exact way I’m doing it right now.

1 Like