Code example for HttpURLConnection

Methods: getContentEncoding, getErrorStream, getInputStream, getResponseCode

0
 
    } 
 
    public Response(HttpURLConnection con) throws IOException {
        this.con = con;
        this.statusCode = con.getResponseCode();
        if (null == (is = con.getErrorStream())) {
            is = con.getInputStream();
        } 
        if (null != is && "gzip".equals(con.getContentEncoding())) {
            // the response is gzipped 
            is = new GZIPInputStream(is);
        } 
    } 
 
    // for test purpose 
    Response(String content) {
        this.responseAsString = content;
    } 
 
    public int getStatusCode() {