Campoie / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

Unable to set charset of multipart/form-data request #239

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create any request that is multipart/form-data.
2. Try sending an xml string with UTF-8 encoding

HttpClientConfig clientConfig = new HttpClientConfig();
clientConfig.httpMultipartMode(HttpMultipartMode.STRICT);

RestAssuredConfig raConfig = new RestAssuredConfig();
raConfig.httpClient(clientConfig);

RequestSpecification req = given().filter(new RequestLoggingFilter(System.out))
                .header(USERID_HEADER, "th\\mdulpers")
                .header(TENANTID_HEADER, "1234")
                .header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON)
                .header(IDMSESSIONID_HEADER, "RandomStringValue")
                .header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA)
                .header(REQUESTID_HEADER, UUID.randomUUID().toString())
                .config(raConfig)
                .multiPart("request", draftInput, "application/xml")
                .multiPart("config", docConfig, "application/xml").post(url);

What is the expected output? What do you see instead?
Actual output is -
"Content-Disposition"
": "
"form-data; name="request""
"[\r][\n]"
"Content-Type"
": "
"application/xml; charset=US-ASCII"
"[\r][\n]"
"Content-Transfer-Encoding"
": "
"8bit"

There is no way to set the charset to UTF-8. Result is a 400 bad request.

What version of the product are you using? On what operating system?
OS: Windows 7 (Microsoft Windows [Version 6.1.7600])
JDK: jdk1.7.0_13
Rest-Assured: 1.8.1-SNAPSHOT

Please provide any additional information below.

Original issue reported on code.google.com by jessica....@gmail.com on 30 May 2013 at 1:27

GoogleCodeExporter commented 9 years ago

Original comment by johan.ha...@gmail.com on 30 May 2013 at 1:45

GoogleCodeExporter commented 9 years ago
Implemented support for this in master. Depend on 1.8.1-SNAPSHOT after having 
added the following repo: 

<repositories>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots />
        </repository>
</repositories>

You should now be able to use the 
com.jayway.restassured.builder.MultiPartSpecBuilder. Please verify it.

Original comment by johan.ha...@gmail.com on 3 Jun 2013 at 6:46