l){
connection.setRequestProperty("Authorization", request.getHeader("Authorization"));
}
if(request.getHeader("Connection") != null){
//TODO HTTP/1.1 proxies MUST parse the Connection header field before a message is forwarded and, for each connection-token in this field, remove any header field(s) from the message with the same name as the connection-token.
//connection.setRequestProperty("Connection", request.getHeader("Connection"));
}
//set de-facto standard proxy headers (x-forwarded-for, others s)
if(request.getHeader("X-Forwarded-For") != null){
connection.setRequestProperty("X-Forwarded-For", request.getHeader("X-Forwarded-For"));//TODO append IP proxy
} else{
connection.setRequestProperty("X-Forwarded-For", request.getRemoteAddr());//TODO append IP proxy
}
}
private void transferHTTPRequestHeadersForPOST(HttpURLConnection connection, HttpServletRequest request){
if(request.getHeader("Content-Type") != null){
connection.setRequestProperty( "Content-Type",request.getContentType());
} else {
//throw exception
}
}
private boolean isAllowedHost(String remoteHost){
//TODO checking of host
return true;
}
}
没有细看,仅供参考,貌似网上第二段用得多些。