fix error with pull file
@@ -216,6 +216,12 @@ rho::net::CNetResponseWrapper CNetRequestWrapper::pushMultipartData(const String
rho::net::CNetResponseWrapper CNetRequestWrapper::pullFile(const String& strUrl, const String& strFilePath, IRhoSession* oSession, Hashtable<String,String>* pHeaders,bool overwriteFile,bool createFolders, bool* pFileExistsFlag )
{
+
+#if defined(OS_WINDOWS_DESKTOP) || defined(OS_ANDROID)
+ const rho::common::ISecurityTokenGenerator* generator = rho_conf_getInt("disable_external_access") ?
+ rho_get_RhoClassFactory()->createSecurityTokenGenerator() : nullptr;
+#endif
+
if (!overwriteFile && common::CRhoFile::isFileExist(strFilePath.c_str())) {
LOGC(WARNING,"Net") + "pullFile: " + strFilePath + " already exists, won't download since overwrite flag is not set";
@@ -247,6 +253,7 @@ rho::net::CNetResponseWrapper CNetRequestWrapper::pullFile(const String& strUrl,
//don't request headers of will overwrite anyway
if (!overwriteFile) {
Hashtable<String, String> h;
+
::getNetRequest().doRequest("HEAD", strUrl, "", oSession, &h );
if ( h.containsKey("last-modified") )
@@ -276,6 +283,19 @@ rho::net::CNetResponseWrapper CNetRequestWrapper::pullFile(const String& strUrl,
return m_pReqImpl->createEmptyNetResponse();
}
+
+#if defined(OS_WINDOWS_DESKTOP) || defined(OS_ANDROID)
+ Hashtable<String,String> headers;
+ if(!pHeaders)
+ pHeaders = &headers;
+ if(generator)
+#if defined(OS_ANDROID)
+ pHeaders->insert(std::make_pair(SECURITY_HEADER, "RhodesAgent RHO-SECURE-TOKEN=" + generator->getSecurityToken()));
+#elif defined(OS_WINDOWS_DESKTOP)
+ pHeaders->insert(std::make_pair(SECURITY_HEADER, generator->getSecurityToken()));
+#endif
+
+#endif
INetResponse* pResp = m_pReqImpl->pullFile( strUrl, tmpFile, oSession, pHeaders );
tmpFile.close();
