Thanks again !
On Mon, 15 Dec 2014 00:06 Stuart Douglas <sdouglas(a)redhat.com> wrote:
I have created
https://issues.jboss.org/browse/UNDERTOW-356, I will
probably get to it some time this week.
BTW the reason why it defaults to ISO-8859-1 is because this is what the
HTTP RFC says is the default, however it appears that in practice often
browsers don't know the charset.
Stuart
----- Original Message -----
> From: "Laurent Bedubourg" <lbedubourg(a)gmail.com>
> To: undertow-dev(a)lists.jboss.org
> Sent: Saturday, 13 December, 2014 8:54:40 PM
> Subject: [undertow-dev] UTF8 form parsing
>
> 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
>
> _______________________________________________
> undertow-dev mailing list
> undertow-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/undertow-dev