Changeset 51635 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Jun 17, 2014 3:58:40 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 94391
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/http.cpp
r46070 r51635 66 66 typedef struct RTHTTPMEMCHUNK 67 67 { 68 char *pszMem;68 uint8_t *pu8Mem; 69 69 size_t cb; 70 70 } RTHTTPMEMCHUNK; … … 146 146 size_t cbAll = cb * n; 147 147 148 pMem->p szMem = (char*)RTMemRealloc(pMem->pszMem, pMem->cb + cbAll + 1);149 if (pMem->p szMem)150 { 151 memcpy(&pMem->p szMem[pMem->cb], pvBuf, cbAll);148 pMem->pu8Mem = (uint8_t*)RTMemRealloc(pMem->pu8Mem, pMem->cb + cbAll + 1); 149 if (pMem->pu8Mem) 150 { 151 memcpy(&pMem->pu8Mem[pMem->cb], pvBuf, cbAll); 152 152 pMem->cb += cbAll; 153 pMem->p szMem[pMem->cb] = '\0';153 pMem->pu8Mem[pMem->cb] = '\0'; 154 154 } 155 155 return cbAll; … … 414 414 } 415 415 416 RTR3DECL(int) RTHttpGet(RTHTTP hHttp, const char *pcszUrl, char **ppszResponse)416 RTR3DECL(int) rtHttpGet(RTHTTP hHttp, const char *pcszUrl, uint8_t **ppvResponse, size_t *pcb) 417 417 { 418 418 PRTHTTPINTERNAL pHttpInt = hHttp; … … 460 460 rcCurl = curl_easy_perform(pHttpInt->pCurl); 461 461 int rc = rtHttpGetCalcStatus(pHttpInt, rcCurl); 462 *ppszResponse = chunk.pszMem; 462 *ppvResponse = chunk.pu8Mem; 463 *pcb = chunk.cb; 463 464 464 465 return rc; 466 } 467 468 469 RTR3DECL(int) RTHttpGetText(RTHTTP hHttp, const char *pcszUrl, char **ppszResponse) 470 { 471 uint8_t *pv; 472 size_t cb; 473 int rc = rtHttpGet(hHttp, pcszUrl, &pv, &cb); 474 *ppszResponse = (char*)pv; 475 return rc; 476 } 477 478 479 RTR3DECL(int) RTHttpGetBinary(RTHTTP hHttp, const char *pcszUrl, void **ppvResponse, size_t *pcb) 480 { 481 return rtHttpGet(hHttp, pcszUrl, (uint8_t**)ppvResponse, pcb); 465 482 } 466 483 -
trunk/src/VBox/Runtime/testcase/tstRTHttp.cpp
r45512 r51635 74 74 // using an intermediate cert which is signed by old root) 75 75 if (RT_SUCCESS(rc)) 76 rc = RTHttpGet (hHttp,77 "http://www.verisign.com/repository/roots/root-certificates/PCA-3G5.pem",78 &pszBuf);76 rc = RTHttpGetText(hHttp, 77 "http://www.verisign.com/repository/roots/root-certificates/PCA-3G5.pem", 78 &pszBuf); 79 79 if (RT_SUCCESS(rc) && pszBuf) 80 80 { … … 146 146 // fetch root CA certificate (old one, but still very widely used) 147 147 if (RT_SUCCESS(rc)) 148 rc = RTHttpGet (hHttp,149 "http://www.verisign.com/repository/roots/root-certificates/PCA-3.pem",150 &pszBuf);148 rc = RTHttpGetText(hHttp, 149 "http://www.verisign.com/repository/roots/root-certificates/PCA-3.pem", 150 &pszBuf); 151 151 if (RT_SUCCESS(rc) && pszBuf) 152 152 { … … 227 227 228 228 if (RT_SUCCESS(rc)) 229 rc = RTHttpGet (hHttp,230 "https://update.virtualbox.org/query.php?platform=LINUX_32BITS_UBUNTU_12_04&version=4.1.18",231 &pszBuf);229 rc = RTHttpGetText(hHttp, 230 "https://update.virtualbox.org/query.php?platform=LINUX_32BITS_UBUNTU_12_04&version=4.1.18", 231 &pszBuf); 232 232 233 233 if ( RT_FAILURE(rc) … … 246 246 } 247 247 248 void *u8Buf; 249 size_t cb; 250 rc = RTHttpGetBinary(hHttp, 251 "http://www.verisign.com/support/roots.zip", 252 &u8Buf, &cb); 253 if (RT_SUCCESS(rc) && u8Buf) 254 { 255 RTPrintf("Got file length %zd\n", cb); 256 } 257 else 258 RTPrintf("Error code %Rrc\n", rc); 259 248 260 RTHttpDestroy(hHttp); 249 261
Note:
See TracChangeset
for help on using the changeset viewer.