VirtualBox

Ignore:
Timestamp:
Jun 17, 2014 3:58:40 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
94391
Message:

introduced RTHttpGetBinary(), renamed RTHttpGet() to RTHttpGetText()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/http.cpp

    r46070 r51635  
    6666typedef struct RTHTTPMEMCHUNK
    6767{
    68     char *pszMem;
     68    uint8_t *pu8Mem;
    6969    size_t cb;
    7070} RTHTTPMEMCHUNK;
     
    146146    size_t cbAll = cb * n;
    147147
    148     pMem->pszMem = (char*)RTMemRealloc(pMem->pszMem, pMem->cb + cbAll + 1);
    149     if (pMem->pszMem)
    150     {
    151         memcpy(&pMem->pszMem[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);
    152152        pMem->cb += cbAll;
    153         pMem->pszMem[pMem->cb] = '\0';
     153        pMem->pu8Mem[pMem->cb] = '\0';
    154154    }
    155155    return cbAll;
     
    414414}
    415415
    416 RTR3DECL(int) RTHttpGet(RTHTTP hHttp, const char *pcszUrl, char **ppszResponse)
     416RTR3DECL(int) rtHttpGet(RTHTTP hHttp, const char *pcszUrl, uint8_t **ppvResponse, size_t *pcb)
    417417{
    418418    PRTHTTPINTERNAL pHttpInt = hHttp;
     
    460460    rcCurl = curl_easy_perform(pHttpInt->pCurl);
    461461    int rc = rtHttpGetCalcStatus(pHttpInt, rcCurl);
    462     *ppszResponse = chunk.pszMem;
     462    *ppvResponse = chunk.pu8Mem;
     463    *pcb = chunk.cb;
    463464
    464465    return rc;
     466}
     467
     468
     469RTR3DECL(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
     479RTR3DECL(int) RTHttpGetBinary(RTHTTP hHttp, const char *pcszUrl, void **ppvResponse, size_t *pcb)
     480{
     481    return rtHttpGet(hHttp, pcszUrl, (uint8_t**)ppvResponse, pcb);
    465482}
    466483
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette