Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.URI$LocaleToCharsetMap


            throw new ParseException(s, 0);

        try {
            int i=s.indexOf(",");        //TODO: relies on s being URL encoded
            if (i<0//simple url
                _url = (new URI(s.toCharArray())).toString();
            else  //extended gnutella.net
                _url = (new URI(s.substring(0,i).toCharArray())).toString();
        } catch (URIException e) {
            throw new ParseException(s, 0);
        }
    }
View Full Code Here


     @param suffix suffix to run scan with.
     @param  replaceSuffix true = replace the suffix for checking.  false = append the suffix.
     */
    private void testSuffix(String suffix, boolean replaceSuffix) throws IOException {
        HttpMessage msg = getNewMsg();
        URI uri = msg.getRequestHeader().getURI();
        String   path   = uri.getPath();
       
        if (path == null || path.equals("")) {
            return;
        }
       
        if (replaceSuffix) {
            int pos = path.lastIndexOf(".");
            if (pos > -1) {
                path = path.substring(0, pos);
            }
        }
       
        path = path + suffix;
       
        uri.setPath(path);
        msg.getRequestHeader().setURI(uri);
       
        sendAndReceive(msg);
       
        if (!isFileExist(msg)) {
            return;
        }       
       
    bingo(Alert.RISK_LOW, Alert.WARNING, uri.toString(), "", "", msg);

       
    }
View Full Code Here

  }
 
  private boolean isRecursive(HttpRequestHeader header) {
        boolean isRecursive = false;
        try {
            URI uri = header.getURI();
            if (uri.getHost().equals(proxyParam.getProxyIp())) {
                if (uri.getPort() == proxyParam.getProxyPort()) {
                    isRecursive = true;
                }
            }
        } catch (Exception e) {
        }
View Full Code Here

     @param suffix suffix to run scan with.
     @param  replaceSuffix true = replace the suffix for checking.  false = append the suffix.
     */
    private void testSuffix(String suffix, boolean replaceSuffix) throws IOException {
        HttpMessage msg = getNewMsg();
        URI uri = msg.getRequestHeader().getURI();
        String   path   = uri.getPath();
       
        if (path == null || path.equals("")) {
            return;
        }
       
        if (replaceSuffix) {
            int pos = path.lastIndexOf(".");
            if (pos > -1) {
                path = path.substring(0, pos);
            }
        }
       
        path = path + suffix;
       
        uri.setPath(path);
        msg.getRequestHeader().setURI(uri);
       
        sendAndReceive(msg);
       
        if (!isFileExist(msg)) {
            return;
        }       
       
    bingo(Alert.RISK_LOW, Alert.WARNING, uri.toString(), "", "", msg);

       
    }
View Full Code Here

     * @return
     * @throws URIException
     */
    private URI buildURI(URI base, String link) throws URIException {

        URI uri = null;
        /*
        try {
            uri = new URI(link, true);
            if (uri.isAbsoluteURI()) {
                return uri;
            }
        } catch (URIException e) {}
        */
       
        uri = new URI(base, link, true);
        return uri;
    }
View Full Code Here

    private boolean isNeglectCrawl(HttpMessage msg) {
        boolean result = false;

       
        URI uri = msg.getRequestHeader().getURI();

        try {
           
            // check if need to skip this URL from config
            if (parent.getSpiderParam().isSkipURL(uri)) {
                return true;
            }
           
            // check if suffix relevant
            if (uri.getPath() != null) {
                String path = uri.getPath().toLowerCase();
                for (int i=0; i<NEGLECT_SUFFIXES.length; i++) {
                    String suffix = "." + NEGLECT_SUFFIXES[i];
                    if (path.endsWith(suffix)) {
                        return true;
                    }
View Full Code Here

    if (node.getHistoryReference() == null) {
        return;
    }
   
    HttpMessage baseMsg = (HttpMessage) node.getHistoryReference().getHttpMessage();
    URI baseUri = (URI) baseMsg.getRequestHeader().getURI().clone();

    baseUri.setQuery(null);
        //System.out.println("analysing: " + baseUri.toString());

   
    // already exist one.  no need to test
    if (mapVisited.get(baseUri.toString()) != null) {
      return;
    }

    String path = getRandomPathSuffix(node, baseUri);
    HttpMessage msg = baseMsg.cloneRequest();
   
    URI uri = (URI) baseUri.clone();
    uri.setPath(path);
    msg.getRequestHeader().setURI(uri);
        //System.out.println("analysing 2: " + uri);
       
    sendAndReceive(msg);

    // standard RFC response, no further check is needed
   
   
    if (msg.getResponseHeader().getStatusCode() == HttpStatusCode.NOT_FOUND) {
      addAnalysedHost(baseUri, msg, SampleResponse.ERROR_PAGE_RFC);
      return;
    }

    if (HttpStatusCode.isRedirection(msg.getResponseHeader().getStatusCode())) {
      addAnalysedHost(baseUri, msg, SampleResponse.ERROR_PAGE_REDIRECT);
      return;
    }
   
    if (msg.getResponseHeader().getStatusCode() != HttpStatusCode.OK) {
      addAnalysedHost(baseUri, msg, SampleResponse.ERROR_PAGE_NON_RFC);
      return;
    }
 
    HttpMessage msg2 = baseMsg.cloneRequest();
    URI uri2 = msg2.getRequestHeader().getURI();
    String path2 = getRandomPathSuffix(node, uri2);
    uri2 = (URI) baseUri.clone();
    uri2.setPath(path2);
    msg2.getRequestHeader().setURI(uri2);
    sendAndReceive(msg2);

    // remove HTML HEAD as this may contain expiry time which dynamic changes   
    String resBody1 = msg.getResponseBody().toString().replaceAll(p_REMOVE_HEADER, "");
View Full Code Here

   
    return resultSuffix;
  }
 
  private String getPathRegex(URI uri) throws URIException {
      URI newUri = (URI) uri.clone();
      String query = newUri.getQuery();
      StringBuffer sb = new StringBuffer(100);
   
    // case should be sensitive
    //sb.append("(?i)");

      newUri.setQuery(null);
     
    sb.append(newUri.toString().replaceAll("\\.", "\\."));
    if (query != null) {
      String queryPattern = "(\\?" + query + ")?";
      sb.append(queryPattern);
    }
   
View Full Code Here

    // RFC
        if (msg.getResponseHeader().getStatusCode() == HttpStatusCode.NOT_FOUND) {
            return false;
        }

        URI uri = (URI) msg.getRequestHeader().getURI().clone();
        try {
            // strip off last part of path - use folder only
            uri.setQuery(null);
            String path = uri.getPath();
            path = path.replaceAll("/[^/]*$","");
            uri.setPath(path);
        } catch (Exception e1) {}
   
        String sUri = uri.toString();       
       
    // get sample with same relative path position when possible.
    // if not exist, use the host only 
    SampleResponse sample = (SampleResponse) mapVisited.get(sUri);
    if (sample == null) {
        try {
                uri.setPath(null);
            } catch (URIException e2) {}
        String sHostOnly = uri.toString();
      sample = (SampleResponse) mapVisited.get(sHostOnly);
    }
   
    // check if any analysed result.

View Full Code Here

        }

    }
   
    public synchronized void addSeed(HttpMessage msg) {
        URI uri = msg.getRequestHeader().getURI();
        String hostName = null;
        int port = 80;
       
        try {
            log.info("seeding " + msg.getRequestHeader().getURI().toString());

            hostName = uri.getHost();
            port = uri.getPort();
            if (port > 0) {
                hostName = hostName + ":" + Integer.toString(port);
            }
           
            seedHostNameSet.add(hostName);
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.URI$LocaleToCharsetMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.