Browser always displays "Could not load page"
Hi,
I have been debugging, after setting up the project in intelliJ. I am not sure what the fix should be.
EnabledWebViewBasedBrowserComponent.java;line 309
breakpoint:
getThreadPool().submit(new BrowserFallbackTask(url, backupUrl));
\Variables example. I did for security reasons, ensured some wildcards. Url was tested in browser and works
url=https://xxx.eu.auth0.com/authorize?audience=something&scope=read%3Ausers&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A3011%2FDebugAuth0%2FGetAccessTokenFromAuth0&client_id=xxx
This is the one set by SoapUi backupUrl=
The page could not be loaded
In belows code it goes wrong verifyReturnCode
@Override
public void run() {
if (!verifyReturnCode(url)) {
loadUrl(backupUrl);
}
}
Parameters are still
url=https://xxx.eu.auth0.com/authorize?audience=something&scope=read%3Ausers&response_type=code&redirect_uri=https%3A%2F%2Flocalhost%3A3011%2FDebugAuth0%2FGetAccessTokenFromAuth0&client_id=xxx
backupUrl=<html><body><h1>The page could not be loaded</h1></body></html>
Go into verifyReturnCode and see the line final URLConnection urlConnection = url.openConnection();
public static boolean verifyReturnCode(String urlString) {
try {
int neededIndex = urlString.indexOf("?");
if (neededIndex != -1) {
urlString = urlString.substring(0, neededIndex);
}
//urlString is now = https://xxx.eu.auth0.com/authorize
URL url = new URL(urlString);
final URLConnection urlConnection = url.openConnection();
if (urlConnection instanceof HttpURLConnection) {
HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnection;
**//line below gives IOException: java.net.ConnectException: Connection refused: connect**
int statusCode = httpURLConnection.getResponseCode();
**gives exception when proxy is not running ( fiddler ) **
return statusCode == HttpURLConnection.HTTP_OK;
// Bug. A good authorizeURI gives 302 back ( redirect ). The stripped version will reult in a 400 BadRequest ==> Here is also a cullprit. But the page cant be loaded still. So need to debug further. Any ideas anyone? Instead on checking what is OK, maybe better checking the range of what is ok?
} else {
return true;
}
} catch (IOException e) {
return false;
}
}
So, my question is how to fix this?
- the HTTP_OK doesnt seem to be correct
- the url.openConnection(); does not use the overload proxy. But I really dont know if this will make a difference.
- why is the responseCode of an incomplete authorizeURL used?
- can there be range of the OK httpstatuscodes ( like 302, 201, 202, 400... )