Thanks again !<br><br><div class="gmail_quote">On Mon, 15 Dec 2014 00:06 Stuart Douglas <<a href="mailto:sdouglas@redhat.com">sdouglas@redhat.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I have created <a href="https://issues.jboss.org/browse/UNDERTOW-356" target="_blank">https://issues.jboss.org/<u></u>browse/UNDERTOW-356</a>, I will probably get to it some time this week.<br>
<br>
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.<br>
<br>
Stuart<br>
<br>
----- Original Message -----<br>
> From: "Laurent Bedubourg" <<a href="mailto:lbedubourg@gmail.com" target="_blank">lbedubourg@gmail.com</a>><br>
> To: <a href="mailto:undertow-dev@lists.jboss.org" target="_blank">undertow-dev@lists.jboss.org</a><br>
> Sent: Saturday, 13 December, 2014 8:54:40 PM<br>
> Subject: [undertow-dev] UTF8 form parsing<br>
><br>
> Hello,<br>
><br>
> I am using utf-8 as default encoding for the web and it didn't worked out of<br>
> the box with Undertow and EagerFormParsingHandler.<br>
><br>
> It turned out that MultiPartParserDefinition has a default iso-8859-1<br>
> encoding and that it's quite hard to change it. You have to create a custom<br>
> FormParserFactory containing a MultiPartParserDefinition with the right<br>
> setDefaultEncoding() that's a lot of work for something that common and I<br>
> had to spend half an hour looking at Undertow sources to understand how it<br>
> work and why my input was garbage.<br>
><br>
> The assumption that Browsers will add a "; charset=UTF-8" to the Content type<br>
> is false (at least with google chrome).<br>
><br>
> My temporary hack is to override EagerFormParsingHandler and modify the<br>
> request CONTENT_TYPE header to add the UTF-8 charset and then setNext my<br>
> real HttpHandler (I had less mental friction doing this than learning how to<br>
> create my custom FormParserFactor).<br>
><br>
> new EagerFormParsingHandler(){<br>
> override def handleRequest(x:<u></u>HttpServerExchange){<br>
> val ct = x.getRequestHeaders().get(<u></u>Headers.CONTENT_TYPE).getLast(<u></u>)<br>
> x.getRequestHeaders().put(<u></u>Headers.CONTENT_TYPE, ct+"; charset=UTF-8")<br>
> super.handleRequest(x)<br>
> }<br>
> }.setNext(new HttpHandler(){<br>
> def handleRequest(x:<u></u>HttpServerExchange){ ... }<br>
> })<br>
><br>
> Now that I know it I can create my own Utf8FormParsingHandler but I imagine<br>
> that other users will want to be able to define the encoding out of the box.<br>
><br>
> Maybe with a new self documenting contructor like :<br>
><br>
> new EagerFormParsingHandler(<u></u>encoding:String, nextHandler:HttpHandler)<br>
><br>
> Best regards<br>
> Laurent<br>
><br>
> ______________________________<u></u>_________________<br>
> undertow-dev mailing list<br>
> <a href="mailto:undertow-dev@lists.jboss.org" target="_blank">undertow-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" target="_blank">https://lists.jboss.org/<u></u>mailman/listinfo/undertow-dev</a><br>
</blockquote></div>