{"action":"created","issue":{"url":"https://api.github.com/repos/jayway/rest-assured/issues/616","labels_url":"https://api.github.com/repos/jayway/rest-assured/issues/616/labels{/name}","comments_url":"https://api.github.com/repos/jayway/rest-assured/issues/616/comments","events_url":"https://api.github.com/repos/jayway/rest-assured/issues/616/events","html_url":"https://github.com/jayway/rest-assured/issues/616","id":116773860,"number":616,"title":"Request content type is set to #toString of response content type object","user":{"login":"ThorbenLindhauer","id":586648,"avatar_url":"https://avatars.githubusercontent.com/u/586648?v=3","gravatar_id":"","url":"https://api.github.com/users/ThorbenLindhauer","html_url":"https://github.com/ThorbenLindhauer","followers_url":"https://api.github.com/users/ThorbenLindhauer/followers","following_url":"https://api.github.com/users/ThorbenLindhauer/following{/other_user}","gists_url":"https://api.github.com/users/ThorbenLindhauer/gists{/gist_id}","starred_url":"https://api.github.com/users/ThorbenLindhauer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThorbenLindhauer/subscriptions","organizations_url":"https://api.github.com/users/ThorbenLindhauer/orgs","repos_url":"https://api.github.com/users/ThorbenLindhauer/repos","events_url":"https://api.github.com/users/ThorbenLindhauer/events{/privacy}","received_events_url":"https://api.github.com/users/ThorbenLindhauer/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-11-13T14:04:29Z","updated_at":"2015-12-18T07:59:02Z","closed_at":"2015-12-18T07:59:02Z","body":"Request that reproduces the issue:\r\n\r\n```java\r\nString url = ...;\r\n\r\ngiven()\r\n    .then().expect().statusCode(Status.OK.getStatusCode())\r\n    .and()\r\n      .contentType(equalTo(ContentType.TEXT))\r\n    .when().get(url);\r\n```\r\n\r\nNote that the response content type is specified with a Hamcrest matcher. When the request is issued, the request content type header is set to `equalTo(ContentType.TEXT).toString()`. This may not be a valid media type, so the request may fail.\r\n\r\nAfter doing some debugging, this seems to be the code that causes the problem: https://github.com/jayway/rest-assured/blob/master/rest-assured/src/main/java/com/jayway/restassured/internal/http/HTTPBuilder.java#L928-L931"},"comment":{"url":"https://api.github.com/repos/jayway/rest-assured/issues/comments/165707846","html_url":"https://github.com/jayway/rest-assured/issues/616#issuecomment-165707846","issue_url":"https://api.github.com/repos/jayway/rest-assured/issues/616","id":165707846,"user":{"login":"johanhaleby","id":187029,"avatar_url":"https://avatars.githubusercontent.com/u/187029?v=3","gravatar_id":"","url":"https://api.github.com/users/johanhaleby","html_url":"https://github.com/johanhaleby","followers_url":"https://api.github.com/users/johanhaleby/followers","following_url":"https://api.github.com/users/johanhaleby/following{/other_user}","gists_url":"https://api.github.com/users/johanhaleby/gists{/gist_id}","starred_url":"https://api.github.com/users/johanhaleby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanhaleby/subscriptions","organizations_url":"https://api.github.com/users/johanhaleby/orgs","repos_url":"https://api.github.com/users/johanhaleby/repos","events_url":"https://api.github.com/users/johanhaleby/events{/privacy}","received_events_url":"https://api.github.com/users/johanhaleby/received_events","type":"User","site_admin":false},"created_at":"2015-12-18T07:59:02Z","updated_at":"2015-12-18T07:59:02Z","body":"Oh now I see what's going on. Please note the type signature of `Matcher<? super String>`:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/187029/11891982/152a1ed4-a564-11e5-9a79-51e9613f44f9.png)\r\n\r\nYou shouldn't pass a `ContentType` to a Hamcrest matcher for validation. Unfortunately Java's type system is too weak to catch the error at compile time and let it slip through. This means that the content-type returned in the response is a String but Hamcrest will try to match it against a `ContentType` and thus fail. What you should do is:\r\n\r\n```java\r\nwhen().\r\n        get(\"/text\").\r\nthen().\r\n        statusCode(200).\r\n        contentType(ContentType.TEXT);\r\n```\r\n\r\nI.e. don't use a Hamcrest matcher.\r\n\r\nI'll close the issue since this is expected behavior and I don't think there's anything we can do about it. If you disagree then feel free to reopen :)"}}