Akka-http: HttpHeader.parse can only use default settings

Created on 4 Jul 2017  路  6Comments  路  Source: akka/akka-http

Currently when using HttpHeader.parse manually there is no way to override the Settings, since they are private.

Actually Play is using it to encode response headers:
https://github.com/playframework/playframework/blob/master/framework/src/play-akka-http-server/src/main/scala/play/core/server/akkahttp/AkkaModelConversion.scala#L276

It would be great if there was a public way on overriding them, even a typesafe Config object would be fine.

help wanted 1 - triaged core play-akka-http-integration

All 6 comments

For reference, what is meant here is that HeaderParser is private[http], so while the param is public and "could" be passed in, one can not obtain an instance of HeaderParser.Settings.

Since it's in public API indeed we should provide a way of getting those settings in the hands of users of it.

You can pass in an instance of public ParserSettings which inherits from HeaderParser.Settings.

Going forward, we should either make HeaderParser.Settings public or change the signature of that method to ParserSettings in the first place.

Hello, I would like to contribute with this issue. I think it would be a good option to move out the settings from HeaderParser and make them public for the user to extend or use.

Good to see you here @aholg :)

Thanks, @aholg, for offering to take on this ticket.

Maybe the simpler change would be to add another overload to HttpHeader.parse which takes akka.http.scaladsl.settings.ParserSettings:

def parse(name: String, value: String, settings: ParserSettings): ParsingResult = 
  parse(name, value, settings: HttpHeader.Settings)

The alternative of making HeaderParser.Settings public might introduce binary incompatible changes (because we would have to touch HttpHeader.parse). If you have an idea how to deal with that a PR with that change would be ok as well. (E.g. introducing a public akka.http.scaladsl.HeaderParserSettings?).

I have no experience with binary incompatible changes and I guess it makes more sense to avoid that approach since it might just complicate things. I can go ahead with your suggested approach.

Was this page helpful?
0 / 5 - 0 ratings