Issue by nartamonov
_Tuesday Mar 22, 2016 at 16:00 GMT_
_Originally opened as https://github.com/akka/akka/issues/20120_
Following path returns response "Timeout-Access =
path("test") {
get {
optionalHeaderValueByName("Timeout-Access") { timeout =>
complete(s"Timeout-Access = ${timeout.get}")
}
}
}
It's because TimeoutAccessImpl does not override toString which inherited by default from scala.Function1.
Comment by ktoso
_Tuesday Mar 22, 2016 at 16:35 GMT_
I'm not quite sure it should print everything it has inside it - it's mostly very internal things (and the entire HttpRequest etc).
I assume you saw it by printing the HttpRequest somewhere - which contains the Timeout-Access header, which contains the impl...
I'd actually say that
1) we don't want to render internals of Timeout-Access - maybe just replace with "..."
and 2) perhaps we should even hide this header from being rendered, it is an implementation detail that we transmit it like that to user code.
Comment by nartamonov
_Wednesday Mar 23, 2016 at 07:59 GMT_
@ktoso, ok, I understand. But how can I retrieve value of timeout from this header? According to official documentation, "the HTTP server layer attaches a Timeout-Access header to the request, which _enables programmatic customization of the timeout period and timeout response for each request individually_". What I want is to extract value of timeout from header to use it later in request processing. For example, to specify timeout when _ask_-ing some actor. headerValueByName() directive gives me 'String', not direct access to TimeoutAccess instance.
Comment by ktoso
_Monday Apr 04, 2016 at 00:47 GMT_
The Timeout-Access header is more designed to control the timeout, not read it. So you're right that there's no clean way to access it currently. I agree it would be good to make this inspectable, even for debugging reasons etc, marking as triaged.
The bad thing about that header: it fails validation in akka-http itself.
We have a proxy that routes requests between different hosts, basically, we generate outgoing http requests by calling "withHost(...)" on an incoming request, preserving all origin request's info that includes Timeout-Access header.
That way we receiving warning from akka on each passed request.
WARN [akka.actor.ActorSystemImpl(Proxy)] HTTP header 'Timeout-Access:
' is not allowed in requests
Maybe we are doing proxying wrong and there's more correct way? Is it possible to avoid generation of that header at all? As final measure we could set akka.actor.* logging to errors only... but that would still fail validation every time somewhere in akka :\
There are always headers that cannot be directly proxied. You can filter it out by name. We should also just ignore internal headers instead of logging a warning.
ref #911
Most helpful comment
The bad thing about that header: it fails validation in akka-http itself.
We have a proxy that routes requests between different hosts, basically, we generate outgoing http requests by calling "withHost(...)" on an incoming request, preserving all origin request's info that includes Timeout-Access header.
That way we receiving warning from akka on each passed request.
Maybe we are doing proxying wrong and there's more correct way? Is it possible to avoid generation of that header at all? As final measure we could set akka.actor.* logging to errors only... but that would still fail validation every time somewhere in akka :\