Package net.sf.jpluck.http

Examples of net.sf.jpluck.http.HttpClient$Worker


    String encoding = cl.getOptionValue("encoding", "ISO-8859-1");

    byte[] data = null;
    if (html.startsWith("http://")) {
      System.out.println("Downloading " + html);
      HttpClient httpClient = new HttpClient();
      HttpResponse response = httpClient.doGet(html);
      data = response.getContent();     
    } else {
      File file = new File(html);
      System.out.println("Reading " + file.getAbsolutePath());
      data = new byte[(int)file.length()];
View Full Code Here


            this.name = name;
        }

        public void run() {
            try {
                HttpClient client = new HttpClient();
                String filename = convertToFilename(name);
                HttpResponse response = client.doGet(rootPath + "/" + filename);
                if (response.getStatusCode() == 200) {
                    byte[] data = response.getContent();
                    if (!JPluckX.getInstance().isWebStart()) {
                        FileOutputStream out = new FileOutputStream(new File(dir, filename));
                        out.write(data);
View Full Code Here

  public void run() {
    if (!spider.isRunning()) {
      return;
    }
    HttpClient httpClient = new HttpClient(ClientConfiguration.getDefault().getDownloadAttempts(),
                         spider.httpTimeout * 1000, spider.jxlDocument.getUserAgent(),
                         ClientConfiguration.getDefault().getAcceptCharset());
    httpClient.setReferrer(referrer);
    try {
      spider.fireRetrievalStarted(uri);

      HttpResponse cached = spider.retrieveFromCache(uri);
      long ifModifiedSince = 0;
      if (cached != null) {
        ifModifiedSince = cached.getDate();
      } else {
        if (Spider.isOffline()) {
          logger.warning("Could not retrieve " + uri + " from HTTP cache.");
          return;
        }
      }

      HttpResponse response;
      if (Spider.isOffline()) {
        response = cached;
        logger.info(response.getStatusCode() + " " + response.getStatusMessage() + ": " + uri);
      } else {
        response = httpClient.doGet(uri, ifModifiedSince, spider.cookieStore);
        logger.info(response.getStatusCode() + " " + response.getStatusMessage() + ": " + uri);
        if (response.getStatusCode() == 304) {
          response = cached;
        }
      }
View Full Code Here

        pack();
    }

    public void run() {
        HttpClient httpClient = new HttpClient();
        try {
            httpClient.addHttpListener(this);
            HttpResponse response = httpClient.doGet(url);
            if (isVisible()) {
                this.response = response;
            }
        } catch (Exception e) {
            exception = e;
        } finally {
            httpClient.removeHttpListener(this);
        }
        hide();
    }
View Full Code Here

            jpluckx.webStart = cl.hasOption("webstart");
            try {
                jpluckx.commandServer.start();
            } catch (IOException e) {
                // JPluck X already active
                HttpClient httpClient = new HttpClient();
                try {
                    String jxls = "";
                    for (int i = 0; i < args.length; i++) {
                        File file = new File(args[i]);
                        jxls += ("jxl" + i + "=" + URLEncoder.encode(file.getAbsolutePath(), "ISO-8859-1"));
                        if (i < (args.length - 1)) {
                            jxls += "&";
                        }
                    }
                    httpClient.doGet("http://127.0.0.1:9126/activate?" + jxls);
                } catch (Exception e2) {
                }
                System.exit(ExitCodes.OK);
            }
View Full Code Here

TOP

Related Classes of net.sf.jpluck.http.HttpClient$Worker

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.