{"action":"created","issue":{"url":"https://api.github.com/repos/jamesdbloom/mockserver/issues/162","repository_url":"https://api.github.com/repos/jamesdbloom/mockserver","labels_url":"https://api.github.com/repos/jamesdbloom/mockserver/issues/162/labels{/name}","comments_url":"https://api.github.com/repos/jamesdbloom/mockserver/issues/162/comments","events_url":"https://api.github.com/repos/jamesdbloom/mockserver/issues/162/events","html_url":"https://github.com/jamesdbloom/mockserver/issues/162","id":98359886,"number":162,"title":"support for emojis is broken as of version 3.9.16","user":{"login":"jolivares","id":1228036,"avatar_url":"https://avatars0.githubusercontent.com/u/1228036?v=3","gravatar_id":"","url":"https://api.github.com/users/jolivares","html_url":"https://github.com/jolivares","followers_url":"https://api.github.com/users/jolivares/followers","following_url":"https://api.github.com/users/jolivares/following{/other_user}","gists_url":"https://api.github.com/users/jolivares/gists{/gist_id}","starred_url":"https://api.github.com/users/jolivares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jolivares/subscriptions","organizations_url":"https://api.github.com/users/jolivares/orgs","repos_url":"https://api.github.com/users/jolivares/repos","events_url":"https://api.github.com/users/jolivares/events{/privacy}","received_events_url":"https://api.github.com/users/jolivares/received_events","type":"User","site_admin":false},"labels":[{"id":29788023,"url":"https://api.github.com/repos/jamesdbloom/mockserver/labels/bug","name":"bug","color":"fc2929","default":true},{"id":97103703,"url":"https://api.github.com/repos/jamesdbloom/mockserver/labels/in%20progress","name":"in progress","color":"207de5","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2015-07-31T10:14:30Z","updated_at":"2017-05-22T07:23:41Z","closed_at":"2017-05-22T07:23:41Z","body":"Trying to use an emoji as response body won't work. It seems some encoding problem has been introduced.\n\nIt works ok with 3.9.15.\n\nThis is a simple test case to reproduce the problem:\n\n``` java\n\n\nimport static org.junit.Assert.assertEquals;\nimport static org.mockserver.model.HttpRequest.request;\nimport static org.mockserver.model.HttpResponse.response;\n\nimport java.io.BufferedReader;\nimport java.io.InputStreamReader;\nimport java.net.HttpURLConnection;\nimport java.net.URL;\n\nimport org.junit.Test;\nimport org.mockserver.integration.ClientAndServer;\nimport org.mockserver.model.Header;\n\npublic class EmojiTest {\n\n    @Test\n    public void test() throws Exception {\n        ClientAndServer mockServer = new ClientAndServer(9090);\n        String expected = \"\\uD83D\\uDE04\";\n\n        mockServer.when(request().withMethod(\"GET\").withPath(\"/emoji\")).respond(\n                response().withStatusCode(200).withHeader(new Header(\"Content-Type\", \"tex/plain\")).withBody(expected));\n\n        URL obj = new URL(\"http://127.0.0.1:9090/emoji\");\n        HttpURLConnection con = (HttpURLConnection) obj.openConnection();\n        BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));\n\n        StringBuilder actual = new StringBuilder();\n        String line;\n        while ((line = in.readLine()) != null) {\n            actual.append(line);\n        }\n\n        assertEquals(expected, actual.toString());\n    }\n}\n```\n"},"comment":{"url":"https://api.github.com/repos/jamesdbloom/mockserver/issues/comments/303019754","html_url":"https://github.com/jamesdbloom/mockserver/issues/162#issuecomment-303019754","issue_url":"https://api.github.com/repos/jamesdbloom/mockserver/issues/162","id":303019754,"user":{"login":"jamesdbloom","id":733179,"avatar_url":"https://avatars2.githubusercontent.com/u/733179?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesdbloom","html_url":"https://github.com/jamesdbloom","followers_url":"https://api.github.com/users/jamesdbloom/followers","following_url":"https://api.github.com/users/jamesdbloom/following{/other_user}","gists_url":"https://api.github.com/users/jamesdbloom/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesdbloom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesdbloom/subscriptions","organizations_url":"https://api.github.com/users/jamesdbloom/orgs","repos_url":"https://api.github.com/users/jamesdbloom/repos","events_url":"https://api.github.com/users/jamesdbloom/events{/privacy}","received_events_url":"https://api.github.com/users/jamesdbloom/received_events","type":"User","site_admin":false},"created_at":"2017-05-22T07:23:41Z","updated_at":"2017-05-22T07:23:41Z","body":"For the JSON issue you mentioned can be please raise a separate issue.\r\n\r\nFor the Emoji issue the problem is there is no charset specified.  The Emoji characters you have specified are not available in the default HTTP character set (ISO/IEC 8859-1), so instead a `?` appears.  If you specify the charset by adding this to the content type header, as below, then the test passes:\r\n\r\n```java\r\nimport static org.junit.Assert.assertEquals;\r\nimport static org.mockserver.model.HttpRequest.request;\r\nimport static org.mockserver.model.HttpResponse.response;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.InputStreamReader;\r\nimport java.net.HttpURLConnection;\r\nimport java.net.URL;\r\n\r\nimport org.junit.Test;\r\nimport org.mockserver.integration.ClientAndServer;\r\nimport org.mockserver.model.Header;\r\n\r\npublic class EmojiTest {\r\n\r\n    @Test\r\n    public void test() throws Exception {\r\n        ClientAndServer mockServer = new ClientAndServer(9090);\r\n        String expected = \"\\uD83D\\uDE04\";\r\n\r\n        mockServer.when(request().withMethod(\"GET\").withPath(\"/emoji\")).respond(\r\n                response().withStatusCode(200).withHeader(new Header(\"Content-Type\", \"tex/plain; charset=utf-8\")).withBody(expected));\r\n\r\n        URL obj = new URL(\"http://127.0.0.1:9090/emoji\");\r\n        HttpURLConnection con = (HttpURLConnection) obj.openConnection();\r\n        BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));\r\n\r\n        StringBuilder actual = new StringBuilder();\r\n        String line;\r\n        while ((line = in.readLine()) != null) {\r\n            actual.append(line);\r\n        }\r\n\r\n        assertEquals(expected, actual.toString());\r\n    }\r\n}\r\n```\r\n\r\nI am closing this ticket because it is now working, particularly with the merged PR from @diwakarbhatt123."}}
{"actor":{"display_login":"jamesdbloom"}}