Hello,
I am using utf-8 as default encoding for the web and it didn't worked out of the box with Undertow and EagerFormParsingHandler.
It turned out that MultiPartParserDefinition has a default iso-8859-1 encoding and that it's quite hard to change it. You have to create a custom FormParserFactory containing a MultiPartParserDefinition with the right setDefaultEncoding() that's a lot of work for something that common and I had to spend half an hour looking at Undertow sources to understand how it work and why my input was garbage.
The assumption that Browsers will add a "; charset=UTF-8" to the Content type is false (at least with google chrome).
My temporary hack is to override EagerFormParsingHandler and modify the request CONTENT_TYPE header to add the UTF-8 charset and then setNext my real HttpHandler (I had less mental friction doing this than learning how to create my custom FormParserFactor).
new EagerFormParsingHandler(){
override def handleRequest(x:HttpServerExchange){
val ct = x.getRequestHeaders().get(Headers.CONTENT_TYPE).getLast()
x.getRequestHeaders().put(Headers.CONTENT_TYPE, ct+"; charset=UTF-8")
super.handleRequest(x)
}
}.setNext(new HttpHandler(){
def handleRequest(x:HttpServerExchange){ ... }
})
Now that I know it I can create my own Utf8FormParsingHandler but I imagine that other users will want to be able to define the encoding out of the box.
Maybe with a new self documenting contructor like :
new EagerFormParsingHandler(encoding:String, nextHandler:HttpHandler)
Best regards
Laurent