コード例 #1
0
ファイル: Browser.java プロジェクト: Lujango/frostwire
 public void updateCookies(final Request request) {
   if (request == null) {
     return;
   }
   final String host = Browser.getHost(request.getUrl());
   Cookies cookies = this.getCookies().get(host);
   if (cookies == null) {
     cookies = new Cookies();
     this.getCookies().put(host, cookies);
   }
   cookies.add(request.getCookies());
 }
コード例 #2
0
ファイル: Browser.java プロジェクト: Lujango/frostwire
  public void forwardCookies(final Request request) {
    if (request == null) {
      return;
    }
    final String host = Browser.getHost(request.getUrl());
    final Cookies cookies = this.getCookies().get(host);
    if (cookies == null) {
      return;
    }

    for (final Cookie cookie : cookies.getCookies()) {
      // Pfade sollten verarbeitet werden...TODO
      if (cookie.isExpired()) {
        continue;
      }
      request.getCookies().add(cookie);
    }
  }
コード例 #3
0
ファイル: Browser.java プロジェクト: Lujango/frostwire
  /**
   * Creates a new GET request.
   *
   * @param string a string including an url
   * @param oldRequest the old request for forwarding cookies to the new request. Can be null, to
   *     ignore old cookies.
   * @return the created GET request
   * @throws IOException Signals that an I/O exception has occurred.
   */
  public Request createGetRequest(String string, final Request oldRequest) throws IOException {
    string = this.getURL(string);
    boolean sendref = true;
    if (this.currentURL == null) {
      sendref = false;
      this.currentURL = string;
    }

    final GetRequest request = new GetRequest(string);
    request.setCustomCharset(this.customCharset);

    // if old request is set, use it's cookies for the new request
    if (oldRequest != null && oldRequest.hasCookies()) {
      request.setCookies(oldRequest.getCookies());
    }

    // doAuth(request);
    /* set Timeouts */
    request.setConnectTimeout(this.getConnectTimeout());
    request.setReadTimeout(this.getReadTimeout());

    request.getHeaders().put("Accept-Language", this.acceptLanguage);
    // request.setFollowRedirects(doRedirects);
    this.forwardCookies(request);
    if (sendref) {
      request.getHeaders().put("Referer", this.currentURL.toString());
    }
    if (this.headers != null) {
      this.mergeHeaders(request);
    }

    // if (this.doRedirects && request.getLocation() != null) {
    // this.openGetConnection(null);
    // } else {
    //
    // currentURL = new URL(string);
    // }
    // return this.request.getHttpConnection();
    return request;
  }