-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UTF-8 encoding problem with MultiPart/RestEasy #10323
Comments
Hi @Kondamon, I created a reproducer according to your specifications and you are right about the behavior. Nevertheless, the HTTPie does not specify the Content-Type for the content field. According to Resteasy's documentation when the content's type is not specified it will use the default, us-ascii. Using the debugger, it seems to be the origin's problem (but does not exclude anyone see it by yourself). However, I tried different ways to override this default but without success.
Oops, it's enabled by default. |
Hi @ejba! Thank you for your effort! I have tried to use Postman to send the form with these settings but without success. Still the same behavior. Here the content-type is provided as UTF-8. |
I tried again but with curl command instead. Successfully obtained the result that you expected. ~ % curl -v -X POST -F "content=Test-Ä;type=text/plain;charset=utf-8" "http://localhost:8080/hello"
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST /hello HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 189
> Content-Type: multipart/form-data; boundary=------------------------bed3af2091f63039
>
* We are completely uploaded and fine
< HTTP/1.1 200 OK
< Content-Length: 7
< Content-Type: text/plain;charset=UTF-8
<
* Connection #0 to host localhost left intact
Test-Ä* Closing connection 0 So it means this is not a bug, it's just a matter of how to specify the content's type. |
Thank you very much! It seems like only curl supports to specify the content type. I have added the |
I can't see how you've solved this issue.
Response:
|
@batraz90 Could you show us how are you performing the request? |
Actually it's a simple HTML form:
but I haven't been able to make it work with Curl or any other Rest Client either. |
I didn't use a html form. But you need to specify the content-type of your |
I've tried that. Doesn't work. |
I tried two ways to specify a charset in a HTML |
Which means it doesn't work with a regular multipart/form-data form ? |
@batraz90 the problem is the browser don't set the |
I solved that issue by adding an Interceptor in my code
|
I was trying to do that but in the vertx extension by instance. My idea was to allow configure the resteasy @gsmet Do you think it is possible doing that? |
I think we could hardcode it to UTF-8 and see if people want to make it configurable. UTF-8 is certainly a better default than the current situation. |
We just merged to master a new Default charset will be UTF-8 but you can tweak it if needed. I will backport this to 1.8.1.Final, that I should release on September 30th. |
Seems to be still an issue with version 2.15.0.Final. Had to use the CharsetInterceptorFilter mentioned above. |
Describe the bug
I develop a rest API with MULTIPART_FORM. But I'm having problems with @consumes charset. I sent some params to the controller which includes German characters. And it didn't work as expected. The characters are not encoded properly, what can also be seen in debugging the properties in VSCode.
Some of the characters that cause the problem:
Instead, I receive:
Expected behavior
To Reproduce
Using httpie:
Response:
Ressource:
Model:
Configuration
# Add your application.properties here, if applicable. <properties> <compiler-plugin.version>3.8.1</compiler-plugin.version> <maven.compiler.parameters>true</maven.compiler.parameters> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <quarkus-plugin.version>1.5.1.Final</quarkus-plugin.version> <quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id> <quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id> <quarkus.platform.version>1.5.1.Final</quarkus.platform.version> <surefire-plugin.version>2.22.1</surefire-plugin.version> </properties>
Environment (please complete the following information):
uname -a
orver
:Darwin Mac.local 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64
java -version
:openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment GraalVM CE 19.3.1 (build 11.0.6+9-jvmci-19.3-b07)
OpenJDK 64-Bit Server VM GraalVM CE 19.3.1 (build 11.0.6+9-jvmci-19.3-b07, mixed mode, sharing)
1.5.1.Final
mvnw --version
orgradlew --version
):Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3
Java version: 11.0.6, vendor: Oracle Corporation, runtime: /Users/christian/.sdkman/candidates/java/19.3.1.r11-grl
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.5", arch: "x86_64", family: "mac"
The text was updated successfully, but these errors were encountered: