private static void mirrorURL(HttpExchange req, String url) {
        System.out.println("PROXY GET: " + url);
        try {
            HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection(proxy);
            for (Entry<String, List<String>> header : req.getRequestHeaders().entrySet()) {
                if (header.getKey().equals("Host")) {
                    continue;
                }
                for (String value : header.getValue()) {
                    con.addRequestProperty(header.getKey(), value);
                }
            }
            con.setConnectTimeout(5000);
            con.setReadTimeout(20000);
            long length = con.getContentLengthLong();
            if (length < 0)
                length = 0;
            System.out.println("Content-Length = " + length);
            req.sendResponseHeaders(con.getResponseCode(), length);
            req.getResponseHeaders().putAll(con.getHeaderFields());
            InputStream in;
            try {
                in = con.getInputStream();
            } catch (IOException e) {
                in = con.getErrorStream();
            }
            OutputStream out = req.getResponseBody();
            long totalLen = 0;
            int readLen = 0;
            do {
                byte[] buf = new byte[8192];
                totalLen += readLen = in.read(buf);
                System.out.println("Sending [" + totalLen + "] [" + readLen + "]");
                if (readLen > 0)
                    out.write(buf, 0, readLen);
            } while (readLen > 0);
            if (readLen < 0)
                totalLen -= readLen;
            System.out.println("Actual Length = " + totalLen);
            in.close();
            out.close();
            con.disconnect();
            req.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }