String headerKey = urlConection.getHeaderFieldKey(1);
if (headerKey == null) {
Logger.log(Logger.WARNING,
"No HeaderKey returned by server. Most likely not started"); //$NON-NLS-1$
String errorMessage = PHPDebugCoreMessages.DebuggerConnection_Problem_1;
throw new DebugException(new Status(IStatus.ERROR,
PHPDebugPlugin.getID(),
IPHPDebugConstants.INTERNAL_ERROR, errorMessage,
null));
}
for (int i = 1; (headerKey = urlConection.getHeaderFieldKey(i)) != null; i++) {
if (headerKey.equals("X-Zend-Debug-Server")) { //$NON-NLS-1$
String headerValue = urlConection
.getHeaderField(headerKey);
if (!headerValue.equals("OK")) { //$NON-NLS-1$
Logger.log(Logger.WARNING,
"Unexpected Header Value returned by Server. " //$NON-NLS-1$
+ headerValue);
String errorMessage = PHPDebugCoreMessages.DebuggerConnection_Problem_2
+ " - " + headerValue; //$NON-NLS-1$
throw new DebugException(new Status(IStatus.ERROR,
PHPDebugPlugin.getID(),
IPHPDebugConstants.INTERNAL_ERROR,
errorMessage, null));
}
break;
}
}
InputStream inputStream = urlConection.getInputStream();
while (inputStream.read() != -1) {
// do nothing on the content returned by standard stream
}
inputStream.close();
}
} catch (UnknownHostException e) {
Logger.logException("Unknown host: " + requestURL.getHost(), e); //$NON-NLS-1$
} catch (ConnectException e) {
Logger.logException("Unable to connect to URL " + requestURL, e); //$NON-NLS-1$
} catch (IOException e) {
Logger.logException("Unable to connect to URL " + requestURL, e); //$NON-NLS-1$
} catch (Exception e) {
Logger.logException(
"Unexpected exception communicating with Web server", e); //$NON-NLS-1$
String errorMessage = e.getMessage();
throw new DebugException(new Status(IStatus.ERROR,
PHPDebugPlugin.getID(), IPHPDebugConstants.INTERNAL_ERROR,
errorMessage, e));
}
}