Exemple #1
0
  public NetResponse pullCookies(String strUrl, String strBody, IRhoSession oSession)
      throws Exception {
    Hashtable headers = new Hashtable();
    m_bIgnoreSuffixOnSim = false;
    m_bCancel = false;

    NetResponse resp = doRequest /*Try*/("POST", strUrl, strBody, oSession, headers);
    if (resp.isOK()) {
      resp.setCharData(resp.getCookies());
      LOG.INFO("pullCookies: " + resp.getCharData());
    }

    return resp;
  }
Exemple #2
0
  public NetResponse pullFile(
      String strUrl, String strFileName, IRhoSession oSession, Hashtable headers) throws Exception {
    IRAFile file = null;
    NetResponse resp = null;

    m_nMaxPacketSize = RhoClassFactory.getNetworkAccess().getMaxPacketSize();
    m_bFlushFileAfterWrite = RhoConf.getInstance().getBool("use_persistent_storage");
    m_bCancel = false;

    try {

      if (!strFileName.startsWith("file:")) {
        try {
          strFileName = FilePath.join(RhoClassFactory.createFile().getDirPath(""), strFileName);
        } catch (IOException x) {
          LOG.ERROR("getDirPath failed.", x);
          throw x;
        }
      }

      file = RhoClassFactory.createFSRAFile();
      file.open(strFileName, "rw");
      file.seek(file.size());

      do {
        resp = pullFile1(strUrl, file, file.size(), oSession, headers);
      } while (!m_bCancel
          && (resp == null || resp.isOK())
          && m_nCurDownloadSize > 0
          && m_nMaxPacketSize > 0);

    } finally {
      if (file != null) {
        file.close();
        file = null;
      }
    }

    copyHashtable(m_OutHeaders, headers);

    return resp != null && !m_bCancel
        ? resp
        : makeResponse("", IHttpConnection.HTTP_INTERNAL_ERROR);
  }
Exemple #3
0
  private NetResponse makeResponse(String strRespBody, int nErrorCode) throws Exception {
    NetResponse pResp = new NetResponse(strRespBody != null ? strRespBody : "", nErrorCode);
    if (pResp.isOK()) pResp.setCookies(makeClientCookie(m_OutHeaders));

    return pResp;
  }