Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to get page source with content encoding gzip using httpClient?
    primarykey
    data
    text
    <p>I am using commons-httpclient 3.1 to read a html page source. It is working fine with all except pages with content encoding as gzip. I am getting incomplete page source.</p> <p>For this page firefox is showing content encoding as gzip. </p> <p>Below are the details</p> <p>Response header:</p> <pre><code>status code: HTTP/1.1 200 OK Date = Wed, 20 Jul 2011 11:29:38 GMT Content-Type = text/html; charset=UTF-8 X-Powered-By = JSF/1.2 Set-Cookie = JSESSIONID=Zqq2Tm8V74L1LJdBzB5gQzwcLQFx1khXNvcnZjNFsQtYw41J7JQH!750321853; path=/; HttpOnly Transfer-Encoding = chunked Content- length =-1 </code></pre> <p>My code to read response :</p> <pre><code>HttpClient httpclient = new HttpClient(); httpclient.getParams().setParameter("http.connection.timeout", new Integer(50000000)); httpclient.getParams().setParameter("http.socket.timeout", new Integer(50000000)); // Create a method instance. GetMethod method = new GetMethod(url); // Provide custom retry handler is necessary method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); BufferedReader reader = null; // Execute the method. int statusCode = httpclient.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { System.err.println("Method failed: " + method.getStatusLine()); strHtmlContent = null; } else { InputStream is = method.getResponseBodyAsStream(); reader = new BufferedReader(new InputStreamReader(is,"ISO8859_8")); String line = null; StringBuffer sbResponseBody = new StringBuffer(); while ((line = reader.readLine()) != null) { sbResponseBody.append(line).append("\n"); } strHtmlContent = sbResponseBody.toString(); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload