String locationHeader = null;
String locationHeader2 = null;
String redirect = "";
URI uri = null;
msg = getNewMsg();
try {
sendAndReceive(msg, false);
if (msg.getResponseHeader().getStatusCode() != HttpStatusCode.MOVED_PERMANENTLY
&& msg.getResponseHeader().getStatusCode() != HttpStatusCode.FOUND) {
// not redirect page, return;
return;
}
locationHeader = msg.getResponseHeader().getHeader(HttpHeader.LOCATION);
if (locationHeader == null) {
return;
}
if (locationHeader.compareToIgnoreCase(value) == 0) {
// URI found in param
redirect = redirect1;
} else if (locationHeader.compareToIgnoreCase(getURLDecode(value)) == 0) {
redirect = getURLEncode(redirect1);
}
if (redirect != null) {
uri = new URI(locationHeader, true);
locationHeader2 = uri.getPathQuery();
if (locationHeader2.compareToIgnoreCase(value) == 0) {
// path and query found in param
redirect = redirect2;
} else if (locationHeader2.compareToIgnoreCase(getURLDecode(value)) == 0) {
redirect = getURLEncode(redirect2);