VirtualBox

Ignore:
Timestamp:
Aug 30, 2018 1:19:36 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
124714
Message:

IPRT/rest: Fixed empty array & map handling by making the begin iteration functions return VERR_JSON_IS_EMPTY rather than letter the query method do that. Made query parameter processing table driven and made it use the right escapeing. bugref:9167

Location:
trunk/src/VBox/Runtime/common/rest
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/rest/RTCRestArrayBase.cpp

    r73977 r73978  
    179179        RTJsonIteratorFree(hIterator);
    180180    }
     181    else if (rcRet == VERR_JSON_IS_EMPTY)
     182        rcRet = VINF_SUCCESS;
    181183    else
    182184        rcRet = a_rCursor.m_pPrimary->addError(a_rCursor, rcRet, "RTJsonIteratorBeginArray failed: %Rrc", rcRet);
  • trunk/src/VBox/Runtime/common/rest/RTCRestClientApiBase.cpp

    r73977 r73978  
    117117                if (strQuery.isNotEmpty())
    118118                {
    119                     if (RT_SUCCESS(rc))
    120                         rc = strFullUrl.appendNoThrow('?');
    121                     if (RT_SUCCESS(rc))
    122                         rc = strFullUrl.appendNoThrow(strQuery);
     119                    Assert(strQuery.startsWith("?"));
     120                    rc = strFullUrl.appendNoThrow(strQuery);
    123121                    strQuery.setNull();
    124122                }
  • trunk/src/VBox/Runtime/common/rest/RTCRestClientRequestBase.cpp

    r73977 r73978  
    112112}
    113113
     114
     115int RTCRestClientRequestBase::doQueryParameters(RTCString *a_pStrQuery, QUERYPARAMDESC const *a_paQueryParams,
     116                                                RTCRestObjectBase const **a_papQueryParamObjs, size_t a_cQueryParams) const
     117{
     118    RTCString strTmpVal;
     119    char chSep = a_pStrQuery->isEmpty() ? '?' : '&';
     120    for (size_t i = 0; i < a_cQueryParams; i++)
     121    {
     122        if ((a_paQueryParams[i].fFlags & RTCRestObjectBase::kCollectionFormat_Mask) != RTCRestObjectBase::kCollectionFormat_multi)
     123        {
     124            int rc = a_papQueryParamObjs[i]->toString(&strTmpVal, a_paQueryParams[i].fFlags);
     125            AssertRCReturn(rc, rc);
     126
     127            rc = a_pStrQuery->appendPrintfNoThrow("%c%RMpq=%RMpq", chSep, a_paQueryParams[i].pszName, strTmpVal.c_str());
     128            AssertRCReturn(rc, rc);
     129
     130            chSep = '&';
     131        }
     132        else
     133        {
     134            AssertFailedReturn(VERR_NOT_IMPLEMENTED);
     135        }
     136    }
     137    return VINF_SUCCESS;
     138}
     139
  • trunk/src/VBox/Runtime/common/rest/RTCRestStringMapBase.cpp

    r73977 r73978  
    175175        RTJsonIteratorFree(hIterator);
    176176    }
     177    else if (rcRet == VERR_JSON_IS_EMPTY)
     178        rcRet = VINF_SUCCESS;
    177179    else
    178180        rcRet = a_rCursor.m_pPrimary->addError(a_rCursor, rcRet, "RTJsonIteratorBegin failed: %Rrc", rcRet);
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