/** * Method to reconnect to the proxy when it decides not to maintain the connection * during handshake. * * @param nextFilter the next filter * @param request the http request */ private void reconnect(final NextFilter nextFilter, final HttpProxyRequest request) { LOGGER.debug("Reconnecting to proxy ..."); final ProxyIoSession proxyIoSession = getProxyIoSession(); // Fires reconnection proxyIoSession.getConnector().connect(new IoSessionInitializer<ConnectFuture>() { @Override public void initializeSession(final IoSession session, ConnectFuture future) { LOGGER.debug("Initializing new session: {}", session); session.setAttribute(ProxyIoSession.PROXY_SESSION, proxyIoSession); proxyIoSession.setSession(session); LOGGER.debug(" setting up proxyIoSession: {}", proxyIoSession); // Reconnection is done so we send the // request to the proxy proxyIoSession.setReconnectionNeeded(false); writeRequest0(nextFilter, request); } }); }
/** * Method to reconnect to the proxy when it decides not to maintain the connection * during handshake. * * @param nextFilter the next filter * @param request the http request */ private void reconnect(final NextFilter nextFilter, final HttpProxyRequest request) { LOGGER.debug("Reconnecting to proxy ..."); final ProxyIoSession proxyIoSession = getProxyIoSession(); // Fires reconnection proxyIoSession.getConnector().connect(new IoSessionInitializer<ConnectFuture>() { @Override public void initializeSession(final IoSession session, ConnectFuture future) { LOGGER.debug("Initializing new session: {}", session); session.setAttribute(ProxyIoSession.PROXY_SESSION, proxyIoSession); proxyIoSession.setSession(session); LOGGER.debug(" setting up proxyIoSession: {}", proxyIoSession); // Reconnection is done so we send the // request to the proxy proxyIoSession.setReconnectionNeeded(false); writeRequest0(nextFilter, request); } }); }
/** * Encodes a HTTP request and sends it to the proxy server. * * @param nextFilter the next filter * @param request the http request */ private void writeRequest0(final NextFilter nextFilter, final HttpProxyRequest request) { try { String data = request.toHttpString(); IoBuffer buf = IoBuffer.wrap(data.getBytes(getProxyIoSession().getCharsetName())); LOGGER.debug(" write:\n{}", data.replace("\r", "\\r").replace("\n", "\\n\n")); writeData(nextFilter, buf); } catch (UnsupportedEncodingException ex) { closeSession("Unable to send HTTP request: ", ex); } }
/** * Encodes a HTTP request and sends it to the proxy server. * * @param nextFilter the next filter * @param request the http request */ private void writeRequest0(final NextFilter nextFilter, final HttpProxyRequest request) { try { String data = request.toHttpString(); IoBuffer buf = IoBuffer.wrap(data.getBytes(getProxyIoSession().getCharsetName())); LOGGER.debug(" write:\n{}", data.replace("\r", "\\r").replace("\n", "\\n\n")); writeData(nextFilter, buf); } catch (UnsupportedEncodingException ex) { closeSession("Unable to send HTTP request: ", ex); } }
LOGGER.debug("Reconnecting to proxy ..."); final ProxyIoSession proxyIoSession = getProxyIoSession();
/** * Encodes a HTTP request and sends it to the proxy server. * * @param nextFilter the next filter * @param request the http request */ private void writeRequest0(final NextFilter nextFilter, final HttpProxyRequest request) { try { String data = request.toHttpString(); IoBuffer buf = IoBuffer.wrap(data.getBytes(getProxyIoSession() .getCharsetName())); LOGGER.debug(" write:\n{}", data.replace("\r", "\\r").replace( "\n", "\\n\n")); writeData(nextFilter, buf); } catch (UnsupportedEncodingException ex) { closeSession("Unable to send HTTP request: ", ex); } }
/** * Calls writeRequest0(NextFilter, HttpProxyRequest) to write the request. * If needed a reconnection to the proxy is done previously. * * @param nextFilter the next filter * @param request the http request */ public void writeRequest(final NextFilter nextFilter, final HttpProxyRequest request) { ProxyIoSession proxyIoSession = getProxyIoSession(); if (proxyIoSession.isReconnectionNeeded()) { reconnect(nextFilter, request); } else { writeRequest0(nextFilter, request); } }
/** * Calls{@link #writeRequest0(NextFilter, HttpProxyRequest)} to write the request. * If needed a reconnection to the proxy is done previously. * * @param nextFilter the next filter * @param request the http request */ public void writeRequest(final NextFilter nextFilter, final HttpProxyRequest request) { ProxyIoSession proxyIoSession = getProxyIoSession(); if (proxyIoSession.isReconnectionNeeded()) { reconnect(nextFilter, request); } else { writeRequest0(nextFilter, request); } }
/** * Calls writeRequest0(NextFilter, HttpProxyRequest) to write the request. * If needed a reconnection to the proxy is done previously. * * @param nextFilter the next filter * @param request the http request */ public void writeRequest(final NextFilter nextFilter, final HttpProxyRequest request) { ProxyIoSession proxyIoSession = getProxyIoSession(); if (proxyIoSession.isReconnectionNeeded()) { reconnect(nextFilter, request); } else { writeRequest0(nextFilter, request); } }
String responseHeader = responseData.getString(getProxyIoSession().getCharset().newDecoder()); entityBodyStartPosition = responseData.position(); String chunkSize = tmp.getString(getProxyIoSession().getCharset().newDecoder()); int pos = chunkSize.indexOf(';'); if (pos >= 0) { String footer = tmp.getString(getProxyIoSession().getCharset().newDecoder()); String[] f = footer.split(":\\s?", 2); StringUtilities.addValueToHeader(parsedResponse.getHeaders(), f[0], f[1], false); responseData.getString(getProxyIoSession().getCharset().newDecoder())); parsedResponse.setBody(responseData.getString(getProxyIoSession().getCharset().newDecoder()));
String responseHeader = responseData.getString(getProxyIoSession().getCharset().newDecoder()); entityBodyStartPosition = responseData.position(); String chunkSize = tmp.getString(getProxyIoSession().getCharset().newDecoder()); int pos = chunkSize.indexOf(';'); if (pos >= 0) { String footer = tmp.getString(getProxyIoSession().getCharset().newDecoder()); String[] f = footer.split(":\\s?", 2); StringUtilities.addValueToHeader(parsedResponse.getHeaders(), f[0], f[1], false); responseData.getString(getProxyIoSession().getCharset().newDecoder())); parsedResponse.setBody(responseData.getString(getProxyIoSession().getCharset().newDecoder()));
.getString(getProxyIoSession().getCharset() .newDecoder()); entityBodyStartPosition = responseData.position(); String chunkSize = tmp.getString(getProxyIoSession() .getCharset().newDecoder()); int pos = chunkSize.indexOf(';'); String footer = tmp.getString(getProxyIoSession() .getCharset().newDecoder()); String[] f = footer.split(":\\s?", 2); responseData.getString(getProxyIoSession().getCharset() .newDecoder())); parsedResponse.setBody(responseData.getString(getProxyIoSession() .getCharset().newDecoder()));