1
votes

I'm trying to implement a transparent proxy with Akka-Http & Akka-Stream.

However, I'm running into an issue where Akka-Http maniuplates and parses the response headers from the upstream server.

For example, when the upstream server sends the following header:

Expires: "0"

Akka will parse this into Expires Header and correct the the value to:

Expires: "Wed, 01 Jan 1800 00:00:00 GMT"

Although start of unix time is better than "0", I don't want this proxy to touch any of the headers. I want the proxy to be transparent and not "fix" any of the headers passing through.

Here is the simple proxy:

Http().bind("localhost", 9000).to(Sink.foreach { connection => logger.info("Accepted new connection from " + connection.remoteAddress) connection handleWith pipeline }).run()

The proxy flow:

Flow[HttpRequest].map(x => (x, UUID.randomUUID().toString()).via(Http().superPool[String]()).map(x => x._1)

I noticed that the http-server configuration allows me to configure and keep the raw request headers, but there doesn't seem to be one for http-client.

raw-request-uri-header = off

Is there way I can configure Akka to leave the header values as is when I respond to the client?

1

1 Answers

1
votes

This is not possible currently.

I wonder how hard it would be to expose such mode, and how much complexity we'd have to pay for it, however I err on the side of this feature not being able to pull its weight.

Feel free to open a ticket for it on http://github.com/akka/akka where we could discuss it further. Some headers are treated specially so we really do want to parse them into the proper model – imagine websocket upgrades, Connection headers etc, so there would have to be a strong case behind this feature request to make it pull its weight IMO.

(I'm currently maintaining Akka HTTP).