Code example for HttpURLConnection

Methods: getContentEncodinggetErrorStreamgetResponseCodegetInputStream

0
    private boolean streamConsumed;
 
 
    public ResponseKill(HttpURLConnection con) throws IOException {
        this.con = con;
        statusCode = con.getResponseCode();
        is = con.getErrorStream();
        if (null == is) {
            is = con.getInputStream();
        } 
        if (null != is && "gzip".equals(con.getContentEncoding())) {
            // the response is gzipped 
            is = new GZIPInputStream(is);
        } 
    } 
 
    // for test purposes 
    /*package*/ 
 
    protected ResponseKill() { } 
Experience pair programming with AI  Get Codota for Java