Correct limit check bug
This commit is contained in:
parent
ba30030a58
commit
30bc6b8e28
@ -25,60 +25,57 @@ public class LimitChecker {
|
|||||||
public static int doYourJob(String baseURL, int minNumber) throws IOException {
|
public static int doYourJob(String baseURL, int minNumber) throws IOException {
|
||||||
int number = minNumber;
|
int number = minNumber;
|
||||||
URL u = null;
|
URL u = null;
|
||||||
int result = -1;
|
boolean redirected = false;
|
||||||
|
Redirection redirection = new Redirection();
|
||||||
|
|
||||||
while(result != 404 )
|
while(!redirected )
|
||||||
{
|
{
|
||||||
u = new URL( baseURL+number+"-2/");
|
String origin = baseURL+number+"-2/";
|
||||||
HttpURLConnection huc = (HttpURLConnection)u.openConnection ();
|
String newUrl = redirection.get(origin);
|
||||||
huc.setRequestMethod ("GET");
|
logger.trace("Origin URL: "+origin+" Result: "+newUrl);
|
||||||
huc.connect ();
|
if(newUrl.equals(origin))
|
||||||
result = huc.getResponseCode();
|
|
||||||
logger.trace("URL: "+u.toString()+" Result: "+result);
|
|
||||||
if(result!=404)
|
|
||||||
number += 500;
|
number += 500;
|
||||||
|
else
|
||||||
|
redirected = true;
|
||||||
}
|
}
|
||||||
number-=400;
|
number-=400;
|
||||||
result = -1;
|
redirected = false;
|
||||||
logger.trace("First pass: "+number);
|
logger.trace("First pass: "+number);
|
||||||
while(result != 404 )
|
while(!redirected )
|
||||||
{
|
{
|
||||||
u = new URL( baseURL+number+"-2/");
|
String origin = baseURL+number+"-2/";
|
||||||
HttpURLConnection huc = (HttpURLConnection)u.openConnection ();
|
String newUrl = redirection.get(origin);
|
||||||
huc.setRequestMethod ("GET");
|
logger.trace("Origin URL: "+origin+" Result: "+newUrl);
|
||||||
huc.connect ();
|
if(newUrl.equals(origin))
|
||||||
result = huc.getResponseCode();
|
|
||||||
logger.trace("URL: "+u.toString()+" Result: "+result);
|
|
||||||
if(result!=404)
|
|
||||||
number += 100;
|
number += 100;
|
||||||
|
else
|
||||||
|
redirected = true;
|
||||||
}
|
}
|
||||||
number-=90;
|
number-=90;
|
||||||
result = -1;
|
redirected = false;
|
||||||
logger.trace("Second pass: "+number);
|
logger.trace("Second pass: "+number);
|
||||||
while(result != 404 )
|
while(!redirected )
|
||||||
{
|
{
|
||||||
u = new URL( baseURL+number+"-2/");
|
String origin = baseURL+number+"-2/";
|
||||||
HttpURLConnection huc = (HttpURLConnection)u.openConnection ();
|
String newUrl = redirection.get(origin);
|
||||||
huc.setRequestMethod ("GET");
|
logger.trace("Origin URL: "+origin+" Result: "+newUrl);
|
||||||
huc.connect ();
|
if(newUrl.equals(origin))
|
||||||
result = huc.getResponseCode();
|
|
||||||
logger.trace("URL: "+u.toString()+" Result: "+result);
|
|
||||||
if(result!=404)
|
|
||||||
number += 10;
|
number += 10;
|
||||||
|
else
|
||||||
|
redirected = true;
|
||||||
}
|
}
|
||||||
number-=9;
|
number-=9;
|
||||||
result = -1;
|
redirected = false;
|
||||||
logger.trace("Third pass: "+number);
|
logger.trace("Third pass: "+number);
|
||||||
while(result != 404 )
|
while(!redirected )
|
||||||
{
|
{
|
||||||
u = new URL( baseURL+number+"-2/");
|
String origin = baseURL+number+"-2/";
|
||||||
HttpURLConnection huc = (HttpURLConnection)u.openConnection ();
|
String newUrl = redirection.get(origin);
|
||||||
huc.setRequestMethod ("GET");
|
logger.trace("Origin URL: "+origin+" Result: "+newUrl);
|
||||||
huc.connect ();
|
if(newUrl.equals(origin))
|
||||||
result = huc.getResponseCode();
|
|
||||||
logger.trace("URL: "+u.toString()+" Result: "+result);
|
|
||||||
if(result!=404)
|
|
||||||
number += 1;
|
number += 1;
|
||||||
|
else
|
||||||
|
redirected = true;
|
||||||
}
|
}
|
||||||
number-=1;
|
number-=1;
|
||||||
logger.trace("Final pass: "+number);
|
logger.trace("Final pass: "+number);
|
||||||
|
Loading…
Reference in New Issue
Block a user