use of org.apache.commons.httpclient.URIException 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.URIException 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.URIException in project Asqatasun by Asqatasun.
the class AsqatasunTextSeedModule method seedLine.
/**
* Handle a read line that is probably a seed.
*
* @param uri String seed-containing line
*/
protected void seedLine(String uri) {
if (!uri.matches("[a-zA-Z][\\w+\\-]+:.*")) {
// Rfc2396 s3.1 scheme,
// minus '.'
// Does not begin with scheme, so try http://
uri = "http://" + uri;
}
try {
UURI uuri = UURIFactory.getInstance(uri);
CrawlURI curi = new CrawlURI(uuri);
curi.setSeed(true);
curi.setSchedulingDirective(SchedulingConstants.MEDIUM);
if (getSourceTagSeeds()) {
curi.setSourceTag(curi.toString());
}
publishAddedSeed(curi);
} catch (URIException e) {
// try as nonseed line as fallback
nonseedLine(uri);
}
}
use of org.apache.commons.httpclient.URIException 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);
}
use of org.apache.commons.httpclient.URIException in project zaproxy by zaproxy.
the class DefaultParseFilter method isFiltered.
@Override
public boolean isFiltered(HttpMessage responseMessage) {
//if it's a file ending in "/.svn/entries", or "/.svn/wc.db", the SVN Entries or Git parsers will process it
//regardless of type, and regardless of whether it exceeds the file size restriction below.
Matcher svnXMLFilenameMatcher, svnSQLiteFilenameMatcher, gitFilenameMatcher;
try {
String fullfilename = responseMessage.getRequestHeader().getURI().getPath();
//handle null paths
if (fullfilename == null)
fullfilename = "";
svnSQLiteFilenameMatcher = svnSQLiteFilenamePattern.matcher(fullfilename);
svnXMLFilenameMatcher = svnXMLFilenamePattern.matcher(fullfilename);
gitFilenameMatcher = gitFilenamePattern.matcher(fullfilename);
if (svnSQLiteFilenameMatcher.find() || svnXMLFilenameMatcher.find() || gitFilenameMatcher.find())
return false;
} catch (URIException e) {
//give other parsers a chance to parse it.
log.error(e);
}
// Check response body size
if (responseMessage.getResponseBody().length() > MAX_RESPONSE_BODY_SIZE) {
if (log.isDebugEnabled()) {
log.debug("Resource too large: " + responseMessage.getRequestHeader().getURI());
}
return true;
}
// If it's a redirection, accept it, as the SpiderRedirectParser will process it
if (HttpStatusCode.isRedirection(responseMessage.getResponseHeader().getStatusCode()))
return false;
// Check response type.
if (!responseMessage.getResponseHeader().isText()) {
if (log.isDebugEnabled()) {
log.debug("Resource is not text: " + responseMessage.getRequestHeader().getURI());
}
return true;
}
return false;
}
Aggregations