mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-23 09:31:32 +01:00
updated pre-flight to correctly skip the proxy if configured to do so
Former-commit-id: ee993ded2a19f2a7fbda3f93c8d53ece43c8b1d1
This commit is contained in:
@@ -22,6 +22,7 @@ import java.io.IOException;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
@@ -151,17 +152,17 @@ public class NexusSearch {
|
|||||||
*/
|
*/
|
||||||
public boolean preflightRequest() {
|
public boolean preflightRequest() {
|
||||||
try {
|
try {
|
||||||
final HttpURLConnection conn = URLConnectionFactory.createHttpURLConnection(new URL(rootURL, "status"));
|
final HttpURLConnection conn = URLConnectionFactory.createHttpURLConnection(new URL(rootURL, "status"), useProxy);
|
||||||
conn.addRequestProperty("Accept", "application/xml");
|
conn.addRequestProperty("Accept", "application/xml");
|
||||||
conn.connect();
|
conn.connect();
|
||||||
if (conn.getResponseCode() != 200) {
|
if (conn.getResponseCode() != 200) {
|
||||||
LOGGER.warning("Expected 200 result from Nexus, got " + conn.getResponseCode());
|
LOGGER.log(Level.WARNING, "Expected 200 result from Nexus, got {0}", conn.getResponseCode());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
final Document doc = builder.parse(conn.getInputStream());
|
final Document doc = builder.parse(conn.getInputStream());
|
||||||
if (doc.getDocumentElement().getNodeName() != "status") {
|
if (!"status".equals(doc.getDocumentElement().getNodeName())) {
|
||||||
LOGGER.warning("Expected root node name of status, got " + doc.getDocumentElement().getNodeName());
|
LOGGER.log(Level.WARNING, "Expected root node name of status, got {0}", doc.getDocumentElement().getNodeName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user