Akka Http Client - disable parsing of custom User-Agent header


(Adam R) #1

When I create request using http client:

_HttpRequest(uri = “http://test.host.com”).addHeader( User-Agent ("aws-sdk-java/1.11.358 Windows_7/6.1 Java_HotSpot™64-Bit_Server_VM/25.121-b13 java/1.8.0_121 scala/2.12.4"))

I noticed that akka http client is parsing header to following vaule (adding spaces after hotspot):

_request List(User-Agent: aws-sdk-java/1.11.358 Windows_7/6.1 Java_HotSpot ™ 64-Bit_Server_VM/25.121-b13 java/1.8.0_121 scala/2.12.4)

I tried following settings without success:
akka {
http {
client.parsing.modeled-header-parsing = off
host-connection-pool.client.parsing.modeled-header-parsing = off
}

Does anyone know how to set user agent header with parsing disabled? I need this for AWS signature, otherwise I get signature error

Thanks!


(Johannes Rudolph) #2

Hi @arempter,

afaik, you are not required to include all headers in the signature. I would only include those headers that contain actual data and need to be protected against change.

In the Alpakka S3 connector we have code to sign akka-http requests. You might use that as an example or maybe just depend on those classes:

Johannes


(Adam R) #3

Hi Johannes,
Thanks for your answer. Maybe I didn’t put some background to what I need to achieve…

I am running akka http server as a proxy to ceph s3. Therefore I “forward” user agent from the client.
Client - aws sdk or aws cli prepares signature and decides on what to put to prepare signature.

Indeed when preparing own request I could skip some headers. But not in my case.

Just also to mention similar setting on the server side seems to work:

server.parsing.modeled-header-parsing = off

It is weird though that client setting doesn’t seem to take effect?

Thanks
Adam


(Johannes Rudolph) #4

Hi Adam,

I see. Indeed, it seems to be impossible to include a RawHeader("User-Agent") in requests due to this line:

That would have been the escape hatch to forward them unchanged. Could you create a ticket? I don’t see why we shouldn’t support overriding User-Agent headers by RawHeader in the client.

Johannes


(Adam R) #5

Thanks for quick answer. I’ll create one.