kshitizmittal / rest-assured

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

Responses of 204 ignore contentType and incorrectly fail validation #411

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
While not required, and somewhat meaningless, the ContentType header of 204 (No 
Content) responses are ignored, and assumed to be the empty string ("").

However, a 204 may include headers, and a contentType(...) validation will fail 
for 204 responses, even if the expected contentType header was present.

It could be argued 204 content type should not be validated, but if it is 
there, and validation is attempted, it should at worst warn that the value has 
no meaning.

What steps will reproduce the problem?
1. Instruct the server to set ContentType: application/json for a 204 response
2. Request the resource, and validate that the contentType is ContentType.JSON

    RestAssured.given().post(requestURL)
        .then()
          .statusCode(204)
          .contentType(ContentType.JSON);

What is the expected output? What do you see instead?

 - Expect the validation to succeed, as both the response code, and contentType are correct

 - Instead, the contentType validation fails with the message:
     Expected content-type "JSON" doesn't match actual content-type "".

What version of the product are you using? On what operating system?

   2.4.1. OSX 10.9, 10.10

Original issue reported on code.google.com by mchen...@gmail.com on 25 Jun 2015 at 4:13