use of org.apache.commons.httpclient.URI in project pinpoint by naver.
the class HttpMethodBaseExecuteMethodInterceptor method getHost.
private String getHost(HttpMethod httpMethod, Object[] args) {
try {
final URI url = httpMethod.getURI();
if (url.isAbsoluteURI()) {
return getEndpoint(url.getHost(), url.getPort());
}
if (isDebug) {
logger.debug("URI is not absolute. {}", url.getURI());
}
// if not found schema, use httpConnection.
final HttpConnection httpConnection = getHttpConnection(args);
if (httpConnection != null) {
final String host = httpConnection.getHost();
int port = httpConnection.getPort();
// if port is default port number.
if (httpConnection.getProtocol() != null && port == httpConnection.getProtocol().getDefaultPort()) {
port = -1;
}
return getEndpoint(host, port);
}
} catch (URIException e) {
// unexpected error, perhaps of user fault.
logger.error("[HttpClient3] Fail get URI", e);
}
return null;
}
use of org.apache.commons.httpclient.URI in project zm-mailbox by Zimbra.
the class ProvUtil method sendSoapMessage.
@Override
public void sendSoapMessage(PostMethod postMethod, Element envelope, HttpState httpState) {
console.println("========== SOAP SEND ==========");
if (debugLevel == SoapDebugLevel.high) {
try {
URI uri = postMethod.getURI();
console.println(uri.toString());
} catch (URIException e) {
if (verboseMode) {
e.printStackTrace(errConsole);
} else {
console.println("Unable to get request URL, error=" + e.getMessage());
}
}
Header[] headers = postMethod.getRequestHeaders();
for (Header header : headers) {
// trim the ending crlf
console.println(header.toString().trim());
}
console.println();
}
sendStart = System.currentTimeMillis();
console.println(envelope.prettyPrint());
console.println("===============================");
}
use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.
the class StandardParameterParser method getTreePath.
@Override
public List<String> getTreePath(HttpMessage msg) throws URIException {
URI uri = msg.getRequestHeader().getURI();
List<String> list = getTreePath(uri);
// Add any structural params (form params) in key order
Map<String, String> formParams = this.parse(msg.getRequestBody().toString());
List<String> keys = new ArrayList<String>(formParams.keySet());
Collections.sort(keys);
for (String key : keys) {
if (this.structuralParameters.contains(key)) {
list.add(formParams.get(key));
}
}
return list;
}
use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.
the class Spider method start.
/* SPIDER PROCESS maintenance - pause, resume, shutdown, etc. */
/**
* Starts the Spider crawling.
*/
public void start() {
log.info("Starting spider...");
this.timeStarted = System.currentTimeMillis();
fetchFilterSeeds();
// seeds and will not stop.
if (seedList == null || seedList.isEmpty()) {
log.warn("No seeds available for the Spider. Cancelling scan...");
notifyListenersSpiderComplete(false);
notifyListenersSpiderProgress(100, 0, 0);
return;
}
if (scanUser != null)
log.info("Scan will be performed from the point of view of User: " + scanUser.getName());
this.controller.init();
this.stopped = false;
this.paused = false;
this.initialized = false;
// Initialize the thread pool
this.threadPool = Executors.newFixedThreadPool(spiderParam.getThreadCount(), new SpiderThreadFactory("ZAP-SpiderThreadPool-" + id + "-thread-"));
// Initialize the HTTP sender
httpSender = new HttpSender(connectionParam, true, HttpSender.SPIDER_INITIATOR);
// Do not follow redirections because the request is not updated, the redirections will be
// handled manually.
httpSender.setFollowRedirect(false);
// Add the seeds
for (URI uri : seedList) {
if (log.isDebugEnabled()) {
log.debug("Adding seed for spider: " + uri);
}
controller.addSeed(uri, HttpRequestHeader.GET);
}
// Mark the process as completely initialized
initialized = true;
}
use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.
the class SpiderController method resourceURIFound.
@Override
public void resourceURIFound(HttpMessage responseMessage, int depth, String uri, boolean shouldIgnore) {
log.debug("New resource found: " + uri);
if (uri == null) {
return;
}
// Create the uri
URI uriV = createURI(uri);
if (uriV == null) {
return;
}
// Check if the uri was processed already
String visitedURI;
try {
visitedURI = URLCanonicalizer.buildCleanedParametersURIRepresentation(uriV, spider.getSpiderParam().getHandleParameters(), spider.getSpiderParam().isHandleODataParametersVisited());
} catch (URIException e) {
return;
}
synchronized (visitedGet) {
if (visitedGet.contains(visitedURI)) {
// log.debug("URI already visited: " + visitedURI);
return;
} else {
visitedGet.add(visitedURI);
}
}
// Check if any of the filters disallows this uri
for (FetchFilter f : fetchFilters) {
FetchStatus s = f.checkFilter(uriV);
if (s != FetchStatus.VALID) {
log.debug("URI: " + uriV + " was filtered by a filter with reason: " + s);
spider.notifyListenersFoundURI(uri, HttpRequestHeader.GET, s);
return;
}
}
// Check if should be ignored and not fetched
if (shouldIgnore) {
log.debug("URI: " + uriV + " is valid, but will not be fetched, by parser reccommendation.");
spider.notifyListenersFoundURI(uri, HttpRequestHeader.GET, FetchStatus.VALID);
return;
}
spider.notifyListenersFoundURI(uri, HttpRequestHeader.GET, FetchStatus.VALID);
// Submit the task
SpiderTask task = new SpiderTask(spider, responseMessage.getRequestHeader().getURI(), uriV, depth, HttpRequestHeader.GET);
spider.submitTask(task);
}
Aggregations