コード例 #1
0
ファイル: NetRequest.cs プロジェクト: raulvejar/rhodes
	    public NetResponse pullFile( String strUrl, String strFileName, IRhoSession oSession, Hashtable<String, String> headers )
	    {
		    NetResponse resp = null;
            m_isPullFile = true;

		    m_bCancel = false;
    	
		    try{

	            if (!strFileName.startsWith("file:")) { 
            	    try{
	            	    strFileName = CFilePath.join(CRhodesApp.getRhoRootPath(), strFileName);
            	    } catch (IOException e) { 
                 	    LOG.ERROR("getDirPath failed.", e);
                    }              	
	            }

                m_pulledFile = RhoClassFactory.createFile();
                m_pulledFile.open(strFileName, CRhoFile.EOpenModes.OpenForReadWrite);
                m_pulledFile.setPosTo(m_pulledFile.size());
			
			    do{
                    resp = doRequest("GET", strUrl, null, oSession, headers, m_pulledFile.size());
			    }while( !m_bCancel && (resp == null || resp.isOK()) && m_nCurDownloadSize > 0);
			
		    }finally{
                if (m_pulledFile != null)
			    {
                    try { m_pulledFile.close(); }
                    catch (IOException e)
                    {
                        LOG.ERROR("file closing failed.", e);
                    }
                    m_pulledFile = null;
			    }
		    }
		
		    copyHashtable(m_OutHeaders, headers);

            m_isPullFile = false;
            m_nCurDownloadSize = 0;
            return resp != null && !m_bCancel ? resp : makeResponse("", Convert.ToInt32(HttpStatusCode.InternalServerError));
	    }