Getting Uri out of HttpResponse


#1

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.


(Johannes Rudolph) #2

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


#3

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