src/main/java/com/findupon/commons/netops/ChloeHttpRequestExecutor.java
/**
	 * Insert proxy headers on non-HTTPS requests.
	 * The proxy prefer IP header can (and should) be sent with every non-HTTPS request.
	 * The proxy location header (used only for open) MUST only be sent on the initial request before an IP is assigned. If you
	 * insert this header on every request, the proxy will not remove it and they will get passed to the remote host.
	 */
Insert proxy headers on non-HTTPS requests.
The proxy prefer IP header can (and should) be sent with every non-HTTPS request.
The proxy location header (used only for open) MUST only be sent on the initial request before an IP is assigned. If you
insert this header on every request, the proxy will not remove it and they will get passed to the remote host.
Insert proxy headers on non - HTTPS requests . The proxy prefer IP header can ( and should ) be sent with every non - HTTPS request . The proxy location header ( used only for open ) MUST only be sent on the initial request before an IP is assigned . If you insert this header on every request the proxy will not remove it and they will get passed to the remote host .
@Override
	protected HttpResponse doSendRequest(HttpRequest request, HttpClientConnection conn, HttpContext context) throws IOException, HttpException {
		RequestMeta requestMeta = (RequestMeta)context.getAttribute(ContextOps.CTX_AGENT_REQUEST_META);
		request.setHeader("Accept-encoding", "gzip");
		request.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
		request.setHeader("Connection", "keep-alive");
		request.setHeader("User-agent", requestMeta.getUserAgent().getAgent());
		request.setHeader("Upgrade-insecure-requests", "1");
		if(requestMeta.nonSSL() && requestMeta.proxyUsed()) {
			if(requestMeta.getProxyIp() != null) {
				request.setHeader(proxySetIpRequestHeader, requestMeta.getProxyIp());
			} else if(ProxyMode.ROTATE_OPEN.equals(requestMeta.getProxyMode())) {
				logger.debug("[ChloeHttpRequestExecutor] - Initial HTTP request, setting country and timeout headers. Host [{}]", requestMeta.getHost());
				request.setHeader(proxyCountryRequestHeader, Locale.US.getCountry());
				request.setHeader(proxyTimeoutRequestHeader, String.valueOf(RequestHelper.getConnectTimeoutSeconds()));
			}
		}
		return super.doSendRequest(request, conn, context);
	}
@ Override protected HttpResponse doSendRequest ( HttpRequest request , HttpClientConnection conn , HttpContext context ) throws IOException , HttpException { RequestMeta requestMeta = ( RequestMeta ) context . getAttribute ( ContextOps . CTX_AGENT_REQUEST_META ) ; request . setHeader ( "Accept-encoding" , "gzip" ) ; request . setHeader ( "Accept" , "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" ) ; request . setHeader ( "Connection" , "keep-alive" ) ; request . setHeader ( "User-agent" , requestMeta . getUserAgent ( ) . getAgent ( ) ) ; request . setHeader ( "Upgrade-insecure-requests" , "1" ) ; if ( requestMeta . nonSSL ( ) && requestMeta . proxyUsed ( ) ) { if ( requestMeta . getProxyIp ( ) != null ) { request . setHeader ( proxySetIpRequestHeader , requestMeta . getProxyIp ( ) ) ; } else if ( ProxyMode . ROTATE_OPEN . equals ( requestMeta . getProxyMode ( ) ) ) { logger . debug ( "[ChloeHttpRequestExecutor] - Initial HTTP request, setting country and timeout headers. Host [{}]" , requestMeta . getHost ( ) ) ; request . setHeader ( proxyCountryRequestHeader , Locale . US . getCountry ( ) ) ; request . setHeader ( proxyTimeoutRequestHeader , String . valueOf ( RequestHelper . getConnectTimeoutSeconds ( ) ) ) ; } } return super . doSendRequest ( request , conn , context ) ; }
Insert proxy headers on non-HTTPS requests.
Insert proxy headers on non - HTTPS requests .