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