when test the proxy server, compare the port in parameter of request and
the port from proxy server.
This commit is contained in:
parent
270c4b8d14
commit
52243ff2f1
|
@ -198,7 +198,7 @@ public class HttpRequestHeader {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
public void buildRequestHeader(HttpURLConnection urlConnection) {
|
||||
public void buildRequestHeader(HttpURLConnection urlConnection, int port) {
|
||||
if (0 == method.length())
|
||||
method = "GET";
|
||||
|
||||
|
@ -241,8 +241,9 @@ public class HttpRequestHeader {
|
|||
urlConnection.addRequestProperty("Authorization", "authorization");
|
||||
|
||||
// add flag show the request from proxy
|
||||
urlConnection.addRequestProperty("FromProxy",
|
||||
Boolean.toString(fromProxy));
|
||||
urlConnection.addRequestProperty("FromProxyPort",
|
||||
Integer.toString(port));
|
||||
|
||||
|
||||
if (0 != unrecognized.length()){
|
||||
String[] unknowHeaders = unrecognized.split(CR);
|
||||
|
|
|
@ -111,7 +111,7 @@ public class RequestHandler implements Runnable {
|
|||
return;
|
||||
}
|
||||
|
||||
this.header.buildRequestHeader(serverConnection);
|
||||
this.header.buildRequestHeader(serverConnection,this.clientSocket.getLocalPort());
|
||||
log.trace("set request header");
|
||||
byte[] requestBody;
|
||||
if (this.header.contentLength > 0) {
|
||||
|
|
|
@ -322,12 +322,11 @@ public class ScriptController extends BaseController {
|
|||
@RequestMapping("testRecordProxy")
|
||||
@ResponseBody
|
||||
public Map<String, Object> testRecordProxy(
|
||||
@RequestHeader HttpHeaders headers) {
|
||||
@RequestHeader HttpHeaders headers,@RequestParam String port) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
// is from proxy
|
||||
boolean isFromProxy = Boolean.parseBoolean(headers
|
||||
.getFirst("FromProxy"));
|
||||
if (isFromProxy) {
|
||||
String proxyPort = headers.getFirst("FromProxyPort");
|
||||
if (proxyPort!=null && proxyPort.equals(port)) {
|
||||
success(map);
|
||||
} else {
|
||||
fail(map, "proxy setting error!");
|
||||
|
|
|
@ -109,7 +109,9 @@ function stopServer() {
|
|||
}
|
||||
|
||||
function testRecordProxy() {
|
||||
$.post("testRecordProxy", {}, function(data) {
|
||||
$.post("testRecordProxy", {
|
||||
port: server.port
|
||||
}, function(data) {
|
||||
if (data.success) {
|
||||
$('#mySecondModal').modal('hide');
|
||||
$('#myThirdModal').modal('show');
|
||||
|
|
Loading…
Reference in New Issue