- Timestamp:
- Aug 22, 2018 4:45:17 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/generic/http-curl.cpp
r73837 r73839 259 259 static int rtHttpDarwinTryConfigProxies(PRTHTTPINTERNAL pThis, CFArrayRef hArrayProxies, CFURLRef hUrlTarget, bool fIgnorePacType); 260 260 #endif 261 static CURLcode rtHttpSetWriteCallback(PRTHTTPINTERNAL pThis, PFNRTHTTPWRITECALLBACK pfnWrite, void *pvUser); 261 262 262 263 … … 2299 2300 * cURL callback for writing data. 2300 2301 */ 2301 static size_t rtHttpWriteData( void *pvBuf, size_t cbUnit, size_t cUnits, void *pvUser)2302 static size_t rtHttpWriteData(char *pcBuf, size_t cbUnit, size_t cUnits, void *pvUser) 2302 2303 { 2303 2304 PRTHTTPINTERNAL pThis = (PRTHTTPINTERNAL)pvUser; … … 2314 2315 if (cbNewSize + 1 <= pThis->Output.Mem.cbAllocated) 2315 2316 { 2316 memcpy(&pThis->Output.Mem.pb[cbCurSize], p vBuf, cbToAppend);2317 memcpy(&pThis->Output.Mem.pb[cbCurSize], pcBuf, cbToAppend); 2317 2318 pThis->Output.Mem.cb = cbNewSize; 2318 2319 pThis->Output.Mem.pb[cbNewSize] = '\0'; … … 2332 2333 if (pbNew) 2333 2334 { 2334 memcpy(&pbNew[cbCurSize], p vBuf, cbToAppend);2335 memcpy(&pbNew[cbCurSize], pcBuf, cbToAppend); 2335 2336 pbNew[cbNewSize] = '\0'; 2336 2337 … … 2402 2403 { 2403 2404 RT_ZERO(pThis->Output.Mem); 2404 int rcCurl = curl_easy_setopt(pThis->pCurl, CURLOPT_WRITEFUNCTION, &rtHttpWriteData); 2405 if (!CURL_FAILURE(rcCurl)) 2406 rcCurl = curl_easy_setopt(pThis->pCurl, CURLOPT_WRITEDATA, (void *)pThis); 2405 int rcCurl = rtHttpSetWriteCallback(pThis, &rtHttpWriteData, (void *)pThis); 2407 2406 if (fNoBody) 2408 2407 { … … 2508 2507 * cURL callback for writing data to a file. 2509 2508 */ 2510 static size_t rtHttpWriteDataToFile( void *pvBuf, size_t cbUnit, size_t cUnits, void *pvUser)2509 static size_t rtHttpWriteDataToFile(char *pcBuf, size_t cbUnit, size_t cUnits, void *pvUser) 2511 2510 { 2512 2511 PRTHTTPINTERNAL pThis = (PRTHTTPINTERNAL)pvUser; 2513 2512 size_t cbWritten = 0; 2514 int rc = RTFileWrite(pThis->Output.hFile, p vBuf, cbUnit * cUnits, &cbWritten);2513 int rc = RTFileWrite(pThis->Output.hFile, pcBuf, cbUnit * cUnits, &cbWritten); 2515 2514 if (RT_SUCCESS(rc)) 2516 2515 return cbWritten; … … 2544 2543 { 2545 2544 pThis->Output.hFile = NIL_RTFILE; 2546 int rcCurl = curl_easy_setopt(pThis->pCurl, CURLOPT_WRITEFUNCTION, &rtHttpWriteDataToFile); 2547 if (!CURL_FAILURE(rcCurl)) 2548 rcCurl = curl_easy_setopt(pThis->pCurl, CURLOPT_WRITEDATA, (void *)pThis); 2545 int rcCurl = rtHttpSetWriteCallback(pThis, &rtHttpWriteDataToFile, (void *)pThis); 2549 2546 if (!CURL_FAILURE(rcCurl)) 2550 2547 { … … 2609 2606 2610 2607 2608 static CURLcode rtHttpSetWriteCallback(PRTHTTPINTERNAL pThis, PFNRTHTTPWRITECALLBACK pfnWrite, void *pvUser) 2609 { 2610 CURLcode rcCurl; 2611 2612 rcCurl = curl_easy_setopt(pThis->pCurl, CURLOPT_WRITEFUNCTION, pfnWrite); 2613 if (CURL_FAILURE(rcCurl)) 2614 return rcCurl; 2615 2616 rcCurl = curl_easy_setopt(pThis->pCurl, CURLOPT_WRITEDATA, pvUser); 2617 if (CURL_FAILURE(rcCurl)) 2618 return rcCurl; 2619 2620 return rcCurl; 2621 } 2622 2623 2611 2624 RTR3DECL(int) RTHttpSetWriteCallback(RTHTTP hHttp, PFNRTHTTPWRITECALLBACK pfnWrite, void *pvUser) 2612 2625 { 2613 CURLcode rcCurl;2614 2615 2626 PRTHTTPINTERNAL pThis = hHttp; 2616 2627 RTHTTP_VALID_RETURN(pThis); 2617 2628 2618 rcCurl = curl_easy_setopt(pThis->pCurl, CURLOPT_WRITEFUNCTION, pfnWrite); 2619 if (CURL_FAILURE(rcCurl)) 2620 return VERR_HTTP_CURL_ERROR; 2621 2622 rcCurl = curl_easy_setopt(pThis->pCurl, CURLOPT_WRITEDATA, pvUser); 2629 CURLcode rcCurl = rtHttpSetWriteCallback(pThis, pfnWrite, pvUser); 2623 2630 if (CURL_FAILURE(rcCurl)) 2624 2631 return VERR_HTTP_CURL_ERROR;
Note:
See TracChangeset
for help on using the changeset viewer.