GithubHelp home page GithubHelp logo

Comments (6)

beleagaalexandra avatar beleagaalexandra commented on June 2, 2024 1

Thank you for you response! We'll work around on that

from http4k.

daviddenton avatar daviddenton commented on June 2, 2024

I think this will be due to the change made to the jetty backend which splits headers with quotes in them:
#1023

from http4k.

beleagaalexandra avatar beleagaalexandra commented on June 2, 2024

Ah, ok. I see.
Then, is this the desired behaviour? I understand that the issue with loosing quotes has been fixed.

from http4k.

s4nchez avatar s4nchez commented on June 2, 2024

@beleagaalexandra can you please provide a snippet creating a Request object with the problematic data (setting the header with your expected quotes/escaping) so we can write a test for it?

from http4k.

beleagaalexandra avatar beleagaalexandra commented on June 2, 2024

In order to intercept the incoming requests, we have a routing http handler and we are also using a filter for parsing the header, but when getting to the parser in the filter, the header is already split.

typealias CustomControl = Map<String, JsonNode>
private object CustomControlHolder : RequestScoped<CustomControl>()
private val mapper = jacksonObjectMapper().configure(JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION, true)
object CaptureCustomControlHeaderFilter {
  private fun parse(json: String): CustomControl? =
      try {
        val node = mapper.readTree(json)
        node.fields().asSequence().associate { (k, v) -> k to v }
      } catch (e: JsonParseException) {
        null
      }
  private val customControlHeader = Header.map(::parse).optional("xxx-Header")
  operator fun invoke(): Filter = Filter { next ->
    { request ->
      try {
        val customControl = customControlHeader(request)
        if (customControl != null) {
          CustomControlHolder.add(customControl)
        }
        next(request)
      } finally {
        CustomControlHolder.clear()
      }
    }
  }
}

from http4k.

s4nchez avatar s4nchez commented on June 2, 2024

@beleagaalexandra we can confirm that this behaviour changed from Jetty 11 to 12.

Unfortunately, that splitting happens before http4k is involved, so your options here are either downgrade to jetty11 (by switching to the http4k-server-jetty11 module) or switch to another server implementation.

from http4k.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.