Good day. I want to get data from the site, for this I use Apache HttpComponents. Request such:
public Header[] sendRequest() throws IOException { CloseableHttpResponse responsePost = null; HttpPost httpPost; httpPost = new HttpPost(urlForRequest); httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8")); responsePost = httpClient.execute(httpPost); HttpEntity entityPost = responsePost.getEntity(); sourceTextFile = EntityUtils.toString(entityPost); responsePost.close(); return responsePost.getHeaders("Location"); } At request of the text of the page the exception takes off
15:39:20,061 ERROR [stderr] java.nio.charset.IllegalCharsetNameException: America/New_York Заголовок ответа содержит ошибочные данные Connection : close Content-Encoding: gzip Content-Length: 20 Content-Type: text/html; charset=America/New_York Date : Thu, 13 Oct 2016 12:41:28 GMT Content-Type given by the site is text / html; charset = America / New_York. Because of this on line
sourceTextFile = EntityUtils.toString(entityPost); getting exception.
How do I get the wrong ContentType header to read the contents of a page to a file?