private void handleProxyRequest(HttpRequest request, OutputStream os, String method) {
        logger.log(FINE, "handleProxyRequest for {0}", request.getUrl());
        URL url = request.getUrl();
        Socket socket;
        InputStream remoteInputStream = null;
        OutputStream remoteOutputStream = null;
        try {
            int port = url.getPort();
            socket = new Socket(url.getHost(), port == -1 ? 80 : port);
            remoteInputStream = socket.getInputStream();
            remoteOutputStream = socket.getOutputStream();
            PrintWriter remotePrintWriter = new PrintWriter(remoteOutputStream);

            String uri = getRawURI(url);
            remotePrintWriter.print(method + " " + uri + " HTTP/1.0\n");
            sendHeaders(request, remotePrintWriter);
            ioUtils.copyNoClose(remoteInputStream, os);
        } catch (IOException e) {
            logger.log(SEVERE, request.getPath(), e);
        } finally {
            ioUtils.closeQuietly(remoteOutputStream);
            ioUtils.closeQuietly(remoteInputStream);
        }
    }