Changeset 72264 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- May 18, 2018 4:14:52 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 122712
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/dbg/dbgcfg.cpp
r69753 r72264 739 739 PFNRTDBGCFGOPEN pfnCallback, void *pvUser1, void *pvUser2) 740 740 { 741 #ifdef IPRT_WITH_HTTP742 741 RT_NOREF_PV(pszUuidMappingSubDir); /** @todo do we bother trying pszUuidMappingSubDir? */ 743 742 RT_NOREF_PV(pszCacheSuffix); /** @todo do we bother trying pszUuidMappingSubDir? */ … … 795 794 796 795 /* 797 * Download the file. 798 */ 799 RTHTTP hHttp; 800 rc = RTHttpCreate(&hHttp); 801 if (RT_FAILURE(rc)) 802 return rc; 803 RTHttpUseSystemProxySettings(hHttp); 804 805 static const char * const s_apszHeaders[] = 806 { 807 "User-Agent: Microsoft-Symbol-Server/6.6.0999.9", 808 "Pragma: no-cache", 809 }; 810 811 rc = RTHttpSetHeaders(hHttp, RT_ELEMENTS(s_apszHeaders), s_apszHeaders); 812 if (RT_SUCCESS(rc)) 813 { 814 char szUrl[_2K]; 815 RTStrPrintf(szUrl, sizeof(szUrl), "%s/%s/%s/%s", pszServer, pszFilename, pszCacheSubDir, pszFilename); 816 817 /** @todo Use some temporary file name and rename it after the operation 818 * since not all systems support read-deny file sharing 819 * settings. */ 820 rtDbgCfgLog2(pThis, "Downloading '%s' to '%s'...\n", szUrl, pszPath); 821 rc = RTHttpGetFile(hHttp, szUrl, pszPath); 822 if (RT_FAILURE(rc)) 823 { 824 RTFileDelete(pszPath); 825 rtDbgCfgLog1(pThis, "%Rrc on URL '%s'\n", rc, szUrl); 826 } 827 if (rc == VERR_HTTP_NOT_FOUND) 828 { 829 /* Try the compressed version of the file. */ 830 pszPath[strlen(pszPath) - 1] = '_'; 831 szUrl[strlen(szUrl) - 1] = '_'; 832 rtDbgCfgLog2(pThis, "Downloading '%s' to '%s'...\n", szUrl, pszPath); 833 rc = RTHttpGetFile(hHttp, szUrl, pszPath); 796 * Download/copy the file. 797 */ 798 char szUrl[_2K]; 799 /* Download URL? */ 800 if ( RTStrIStartsWith(pszServer, "http://") 801 || RTStrIStartsWith(pszServer, "https://") 802 || RTStrIStartsWith(pszServer, "ftp://") ) 803 { 804 #ifdef IPRT_WITH_HTTP 805 RTHTTP hHttp; 806 rc = RTHttpCreate(&hHttp); 807 if (RT_SUCCESS(rc)) 808 { 809 RTHttpUseSystemProxySettings(hHttp); 810 811 static const char * const s_apszHeaders[] = 812 { 813 "User-Agent: Microsoft-Symbol-Server/6.6.0999.9", 814 "Pragma: no-cache", 815 }; 816 817 rc = RTHttpSetHeaders(hHttp, RT_ELEMENTS(s_apszHeaders), s_apszHeaders); 834 818 if (RT_SUCCESS(rc)) 835 rc = rtDbgCfgUnpackMsCacheFile(pThis, pszPath, pszFilename); 836 else 837 { 838 rtDbgCfgLog1(pThis, "%Rrc on URL '%s'\n", rc, pszPath); 819 { 820 RTStrPrintf(szUrl, sizeof(szUrl), "%s/%s/%s/%s", pszServer, pszFilename, pszCacheSubDir, pszFilename); 821 822 /** @todo Use some temporary file name and rename it after the operation 823 * since not all systems support read-deny file sharing 824 * settings. */ 825 rtDbgCfgLog2(pThis, "Downloading '%s' to '%s'...\n", szUrl, pszPath); 826 rc = RTHttpGetFile(hHttp, szUrl, pszPath); 827 if (RT_FAILURE(rc)) 828 { 829 RTFileDelete(pszPath); 830 rtDbgCfgLog1(pThis, "%Rrc on URL '%s'\n", rc, szUrl); 831 } 832 if (rc == VERR_HTTP_NOT_FOUND) 833 { 834 /* Try the compressed version of the file. */ 835 pszPath[strlen(pszPath) - 1] = '_'; 836 szUrl[strlen(szUrl) - 1] = '_'; 837 rtDbgCfgLog2(pThis, "Downloading '%s' to '%s'...\n", szUrl, pszPath); 838 rc = RTHttpGetFile(hHttp, szUrl, pszPath); 839 if (RT_SUCCESS(rc)) 840 rc = rtDbgCfgUnpackMsCacheFile(pThis, pszPath, pszFilename); 841 else 842 { 843 rtDbgCfgLog1(pThis, "%Rrc on URL '%s'\n", rc, pszPath); 844 RTFileDelete(pszPath); 845 } 846 } 847 } 848 849 RTHttpDestroy(hHttp); 850 } 851 #else 852 rc = VWRN_NOT_FOUND; 853 #endif 854 } 855 /* No download, assume dir on server share. */ 856 else 857 { 858 if (RTStrIStartsWith(pszServer, "file:///")) 859 pszServer += 4 + 1 + 3 - 1; 860 861 /* Compose the path to the uncompressed file on the server. */ 862 rc = RTPathJoin(szUrl, sizeof(szUrl), pszServer, pszFilename); 863 if (RT_SUCCESS(rc)) 864 rc = RTPathAppend(szUrl, sizeof(szUrl), pszCacheSubDir); 865 if (RT_SUCCESS(rc)) 866 rc = RTPathAppend(szUrl, sizeof(szUrl), pszFilename); 867 if (RT_SUCCESS(rc)) 868 { 869 rtDbgCfgLog2(pThis, "Copying '%s' to '%s'...\n", szUrl, pszPath); 870 rc = RTFileCopy(szUrl, pszPath); 871 if (RT_FAILURE(rc)) 872 { 839 873 RTFileDelete(pszPath); 840 } 841 } 842 } 843 844 RTHttpDestroy(hHttp); 845 874 rtDbgCfgLog1(pThis, "%Rrc on '%s'\n", rc, szUrl); 875 876 /* Try the compressed version. */ 877 pszPath[strlen(pszPath) - 1] = '_'; 878 szUrl[strlen(szUrl) - 1] = '_'; 879 rtDbgCfgLog2(pThis, "Copying '%s' to '%s'...\n", szUrl, pszPath); 880 rc = RTFileCopy(szUrl, pszPath); 881 if (RT_SUCCESS(rc)) 882 rc = rtDbgCfgUnpackMsCacheFile(pThis, pszPath, pszFilename); 883 else 884 { 885 rtDbgCfgLog1(pThis, "%Rrc on '%s'\n", rc, pszPath); 886 RTFileDelete(pszPath); 887 } 888 } 889 } 890 } 846 891 if (RT_SUCCESS(rc)) 847 892 { … … 869 914 870 915 return rc; 871 872 #else /* !IPRT_WITH_HTTP */873 RT_NOREF_PV(pThis); RT_NOREF_PV(pszServer); RT_NOREF_PV(pszPath); RT_NOREF_PV(pszCacheSubDir);874 RT_NOREF_PV(pszUuidMappingSubDir); RT_NOREF_PV(pSplitFn); RT_NOREF_PV(pszCacheSuffix); RT_NOREF_PV(fFlags);875 RT_NOREF_PV(pfnCallback); RT_NOREF_PV(pvUser1); RT_NOREF_PV(pvUser2);876 return VWRN_NOT_FOUND;877 #endif /* !IPRT_WITH_HTTP */878 916 } 879 917
Note:
See TracChangeset
for help on using the changeset viewer.