Examples of HttpResult


Examples of com.azwul.api.model.result.HttpResult

    } catch (Exception e) {
      post.releaseConnection();
      throw new AzwulApiException(e);
    }

    HttpResult httpResult = new HttpResult();
    httpResult.setHttpMethod(post);
    httpResult.setSessionToken(sessionToken);

    return httpResult;

  }
View Full Code Here

Examples of com.azwul.api.model.result.HttpResult

    } catch (Exception e) {
      get.releaseConnection();
      throw new AzwulApiException(e);
    }

    HttpResult httpResult = new HttpResult();
    httpResult.setHttpMethod(get);
    httpResult.setSessionToken(sessionToken);

    return httpResult;

  }
View Full Code Here

Examples of com.azwul.api.model.result.HttpResult

    } catch (Exception e) {
      filePost.releaseConnection();
      throw new AzwulApiException(e);
    }

    HttpResult httpResult = new HttpResult();
    httpResult.setHttpMethod(filePost);
    httpResult.setSessionToken(sessionToken);

    return httpResult;
  }
View Full Code Here

Examples of com.azwul.api.model.result.HttpResult

    Map<String, String> params = new HashMap<String, String>();
    params.put("j_password", password);
    params.put("apiId", apiId);

    HttpResult httpResult = httpHelper.doPostMultipart(
        "/j_spring_security_check", httpConfiguration, null, p12,
        "j_key", params);

    String setCookie = httpResult.getHttpMethod()
        .getResponseHeader("Set-Cookie").getValue();

    httpResult.releaseConnection();

    SessionToken sessionToken = new SessionToken();
    sessionToken.setApiId(apiId);
    sessionToken.setCookie(setCookie);

    httpResult.setSessionToken(sessionToken);
    return isLogged(sessionToken);
  }
View Full Code Here

Examples of com.commafeed.backend.HttpGetter.HttpResult

      return Response.status(Status.FORBIDDEN).build();
    }

    url = FeedUtils.imageProxyDecoder(url);
    try {
      HttpResult result = httpGetter.getBinary(url, 20000);
      return Response.ok(result.getContent()).build();
    } catch (Exception e) {
      return Response.status(Status.SERVICE_UNAVAILABLE).entity(e.getMessage()).build();
    }
  }
View Full Code Here

Examples of com.commafeed.backend.HttpGetter.HttpResult

    String contentType = null;

    try {
      log.debug("Getting Facebook user's icon, {}", url);

      HttpResult iconResult = getter.getBinary(iconUrl, TIMEOUT);
      bytes = iconResult.getContent();
      contentType = iconResult.getContentType();
    } catch (Exception e) {
      log.debug("Failed to retrieve YouTube icon", e);
    }

    if (!isValidIconResponse(bytes, contentType)) {
View Full Code Here

Examples of com.commafeed.backend.HttpGetter.HttpResult

    String contentType = null;

    try {
      url = FeedUtils.removeTrailingSlash(url) + "/favicon.ico";
      log.debug("getting root icon at {}", url);
      HttpResult result = getter.getBinary(url, TIMEOUT);
      bytes = result.getContent();
      contentType = result.getContentType();
    } catch (Exception e) {
      log.debug("Failed to retrieve iconAtRoot for url {}: ", url, e);
    }

    if (!isValidIconResponse(bytes, contentType)) {
View Full Code Here

Examples of com.commafeed.backend.HttpGetter.HttpResult

  private byte[] getIconInPage(String url) {

    Document doc = null;
    try {
      HttpResult result = getter.getBinary(url, TIMEOUT);
      doc = Jsoup.parse(new String(result.getContent()), url);
    } catch (Exception e) {
      log.debug("Failed to retrieve page to find icon", e);
      return null;
    }

    Elements icons = doc.select("link[rel~=(?i)^(shortcut|icon|shortcut icon)$]");

    if (icons.isEmpty()) {
      log.debug("No icon found in page {}", url);
      return null;
    }

    String href = icons.get(0).attr("abs:href");
    if (StringUtils.isBlank(href)) {
      log.debug("No icon found in page");
      return null;
    }

    log.debug("Found unconfirmed iconInPage at {}", href);

    byte[] bytes = null;
    String contentType = null;
    try {
      HttpResult result = getter.getBinary(href, TIMEOUT);
      bytes = result.getContent();
      contentType = result.getContentType();
    } catch (Exception e) {
      log.debug("Failed to retrieve icon found in page {}", href, e);
      return null;
    }
View Full Code Here

Examples of com.commafeed.backend.HttpGetter.HttpResult

    try {
      log.debug("Getting YouTube user's icon, {}", url);

      // initial get to translate username to obscure user thumbnail URL
      HttpResult profileResult = getter.getBinary(profileUrl, TIMEOUT);
      Document doc = Jsoup.parse(new String(profileResult.getContent()), profileUrl);

      Elements thumbnails = doc.select("media|thumbnail");
      if (thumbnails.isEmpty()) {
        return null;
      }
      String thumbnailUrl = thumbnails.get(0).attr("abs:url");

      // final get to actually retrieve the thumbnail
      HttpResult iconResult = getter.getBinary(thumbnailUrl, TIMEOUT);
      bytes = iconResult.getContent();
      contentType = iconResult.getContentType();
    } catch (Exception e) {
      log.debug("Failed to retrieve YouTube icon", e);
    }

    if (!isValidIconResponse(bytes, contentType)) {
View Full Code Here

Examples of com.commafeed.backend.HttpGetter.HttpResult

    log.debug("Fetching feed {}", feedUrl);
    FetchedFeed fetchedFeed = null;

    int timeout = 20000;

    HttpResult result = getter.getBinary(feedUrl, lastModified, eTag, timeout);
    byte[] content = result.getContent();

    try {
      fetchedFeed = parser.parse(feedUrl, content);
    } catch (FeedException e) {
      if (extractFeedUrlFromHtml) {
        String extractedUrl = extractFeedUrl(StringUtils.newStringUtf8(result.getContent()), feedUrl);
        if (org.apache.commons.lang3.StringUtils.isNotBlank(extractedUrl)) {
          feedUrl = extractedUrl;

          result = getter.getBinary(extractedUrl, lastModified, eTag, timeout);
          content = result.getContent();
          fetchedFeed = parser.parse(feedUrl, content);
        } else {
          throw e;
        }
      } else {
        throw e;
      }
    }

    if (content == null) {
      throw new IOException("Feed content is empty.");
    }

    String hash = DigestUtils.sha1Hex(content);
    if (lastContentHash != null && hash != null && lastContentHash.equals(hash)) {
      log.debug("content hash not modified: {}", feedUrl);
      throw new NotModifiedException("content hash not modified");
    }

    if (lastPublishedDate != null && fetchedFeed.getFeed().getLastPublishedDate() != null
        && lastPublishedDate.getTime() == fetchedFeed.getFeed().getLastPublishedDate().getTime()) {
      log.debug("publishedDate not modified: {}", feedUrl);
      throw new NotModifiedException("publishedDate not modified");
    }

    Feed feed = fetchedFeed.getFeed();
    feed.setLastModifiedHeader(result.getLastModifiedSince());
    feed.setEtagHeader(FeedUtils.truncate(result.getETag(), 255));
    feed.setLastContentHash(hash);
    fetchedFeed.setFetchDuration(result.getDuration());
    fetchedFeed.setUrlAfterRedirect(result.getUrlAfterRedirect());
    return fetchedFeed;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.