dharmendrakshl1 / rest-assured

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

RestAssured.requestContentType() does not set the Content-Type header #365

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
 Run a test that looks like:
    @Test
    public void acceptHeaderNotSet() {
        RestAssured.config = newConfig().sslConfig(sslConfig().relaxedHTTPSValidation());
        RestAssured.requestContentType(ContentType.JSON);
        RestAssured.baseURI = "https://localhost:8686/api/1.0";

        RestAssured.given()
            .log().all()
            .auth().preemptive().basic("admin", "admin")
        .when()
            .get("/advertisers")
        .then()
            .log().all()
            .statusCode(200);
    }

What is the expected output? What do you see instead?
Since I set the default requestContentType to JSON, I expect the logged request 
to contain the "Content-Type" header set to the "application/json" value.

Instead, I see a logged request that contains no "Content-Type" header. It 
looks like this:
    15:59:33.448 [main] DEBUG org.apache.http.wire - >> "GET /api/1.0/advertisers HTTP/1.1[\r][\n]"
    15:59:33.449 [main] DEBUG org.apache.http.wire - >> "Accept: */*[\r][\n]"
    15:59:33.449 [main] DEBUG org.apache.http.wire - >> "Authorization: Basic YWRtaW46YWRtaW4=[\r][\n]"
    15:59:33.449 [main] DEBUG org.apache.http.wire - >> "Host: localhost:8686[\r][\n]"
    15:59:33.449 [main] DEBUG org.apache.http.wire - >> "Connection: Keep-Alive[\r][\n]"
    15:59:33.449 [main] DEBUG org.apache.http.wire - >> "User-Agent: Apache-HttpClient/4.2.6 (java 1.5)[\r][\n]"
    15:59:33.449 [main] DEBUG org.apache.http.wire - >> "Accept-Encoding: gzip,deflate[\r][\n]"
    15:59:33.449 [main] DEBUG org.apache.http.wire - >> "[\r][\n]"

Note: the request log, though, shows me the Content-Type header, even though it 
never gets sent over the wire:
    Request method: GET
    Request path:   https://localhost:8686/api/1.0/advertisers
    Proxy:      <none>
    Request params: <none>
    Query params:   <none>
    Form params:    <none>
    Path params:    <none>
    Multiparts: <none>
    Headers:    Content-Type=application/json
            Authorization=Basic YWRtaW46YWRtaW4=
    Cookies:    <none>
    Body:       <none>

What version of the product are you using? On what operating system?
I am using v2.3.2, on Windows 8.1

Original issue reported on code.google.com by gabriel....@gmail.com on 23 Oct 2014 at 8:08

GoogleCodeExporter commented 9 years ago
This should be fixed. Please try the latest snapshot, 2.3.5-SNAPSHOT after 
having added the following repo:

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

Original comment by johan.ha...@gmail.com on 24 Oct 2014 at 5:15

GoogleCodeExporter commented 9 years ago
Thanks, this is fixed for me in 2.4.0.

Original comment by gabriel....@gmail.com on 18 Nov 2014 at 5:07