| | |
| | | * @author WWW |
| | | */ |
| | | public class HttpHelper { |
| | | private final static String HTTP_SLASH2 = "://"; |
| | | |
| | | private final static String HTTP_SLASH = "/"; |
| | | |
| | | private final static Integer THREE = 3; |
| | | |
| | | protected static final HeaderGroup HOP_HEADERS; |
| | | |
| | | static { |
| | |
| | | proxyResponse = client.execute(host, proxyRequest); |
| | | |
| | | int statusCode = proxyResponse.getStatusLine().getStatusCode(); |
| | | response.setStatus(statusCode); // response.setStatus(statusCode, proxyResponse.getStatusLine().getReasonPhrase()); |
| | | // response.setStatus(statusCode, proxyResponse.getStatusLine().getReasonPhrase()) |
| | | response.setStatus(statusCode); |
| | | |
| | | copyResponseHeaders(proxyResponse, request, response, url); |
| | | |
| | |
| | | } |
| | | |
| | | protected void copyRequestHeader(HttpServletRequest request, HttpRequest proxyRequest, HttpHost host, String headerName) { |
| | | if (headerName.equalsIgnoreCase(HttpHeaders.CONTENT_LENGTH)||HOP_HEADERS.containsHeader(headerName)) { |
| | | if (headerName.equalsIgnoreCase(HttpHeaders.CONTENT_LENGTH) || HOP_HEADERS.containsHeader(headerName)) { |
| | | return; |
| | | } |
| | | |
| | |
| | | protected String getRealCookie(String cookieValue) { |
| | | StringBuilder escapedCookie = new StringBuilder(); |
| | | |
| | | String cookies[] = cookieValue.split("[;,]"); |
| | | String[] cookies = cookieValue.split("[;,]"); |
| | | for (String cookie : cookies) { |
| | | String cookieSplit[] = cookie.split("="); |
| | | String[] cookieSplit = cookie.split("="); |
| | | if (cookieSplit.length == 2) { |
| | | String cookieName = cookieSplit[0].trim(); |
| | | if (cookieName.startsWith(cookieName)) { |
| | |
| | | .setSocketTimeout(-1) |
| | | .build(); |
| | | |
| | | //return HttpClientBuilder.create() |
| | | // .setDefaultRequestConfig(requestConfig) |
| | | // .build(); |
| | | |
| | | // return HttpClientBuilder.create().setDefaultRequestConfig(requestConfig).build() |
| | | return HttpClients.custom() |
| | | .setDefaultRequestConfig(requestConfig) |
| | | .build(); |
| | |
| | | StringBuffer curUrl = request.getRequestURL(); |
| | | |
| | | int pos; |
| | | if ((pos = curUrl.indexOf("://")) >= 0) { |
| | | if ((pos = curUrl.indexOf("/", pos + 3)) >= 0) { |
| | | if ((pos = curUrl.indexOf(HTTP_SLASH2)) >= 0) { |
| | | if ((pos = curUrl.indexOf(HTTP_SLASH, pos + THREE)) >= 0) { |
| | | curUrl.setLength(pos); |
| | | } |
| | | } |