Changeset 74020 in vbox for trunk/src/VBox/Runtime/common/rest
- Timestamp:
- Sep 1, 2018 8:57:46 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 124766
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/rest/RTCRestClientRequestBase.cpp
r73978 r74020 77 77 78 78 int RTCRestClientRequestBase::doPathParameters(RTCString *a_pStrPath, const char *a_pszPathTemplate, size_t a_cchPathTemplate, 79 PATHREPLACEENTRY *a_paPathParams, size_t a_cPathParams) const 79 PATHPARAMDESC const *a_paPathParams, PATHPARAMSTATE *a_paPathParamStates, 80 size_t a_cPathParams) const 80 81 { 81 82 int rc = a_pStrPath->assignNoThrow(a_pszPathTemplate, a_cchPathTemplate); … … 87 88 char const *psz = strstr(a_pszPathTemplate, a_paPathParams[i].pszName); 88 89 AssertReturn(psz, VERR_INTERNAL_ERROR_5); 89 a_paPathParam s[i].offName = psz - a_pszPathTemplate;90 a_paPathParamStates[i].offName = psz - a_pszPathTemplate; 90 91 } 91 92 … … 94 95 for (size_t i = 0; i < a_cPathParams; i++) 95 96 { 96 rc = a_paPathParams[i].pObj->toString(&strTmpVal, a_paPathParams[i].fFlags); 97 AssertReturn( (a_paPathParams[i].fFlags & RTCRestObjectBase::kCollectionFormat_Mask) 98 != RTCRestObjectBase::kCollectionFormat_multi, 99 VERR_INTERNAL_ERROR_3); 100 AssertMsg(m_fIsSet & RT_BIT_64(a_paPathParams[i].iBitNo), 101 ("Path parameter '%s' is not set!\n", a_paPathParams[i].pszName)); 102 103 rc = a_paPathParamStates[i].pObj->toString(&strTmpVal, a_paPathParams[i].fFlags); 97 104 AssertRCReturn(rc, rc); 98 105 99 106 /* Replace. */ 100 107 ssize_t cchAdjust = strTmpVal.length() - a_paPathParams[i].cchName; 101 rc = a_pStrPath->replaceNoThrow(a_paPathParam s[i].offName, a_paPathParams[i].cchName, strTmpVal);108 rc = a_pStrPath->replaceNoThrow(a_paPathParamStates[i].offName, a_paPathParams[i].cchName, strTmpVal); 102 109 AssertRCReturn(rc, rc); 103 110 … … 105 112 if (cchAdjust != 0) 106 113 for (size_t j = i + 1; j < a_cPathParams; j++) 107 if (a_paPathParam s[j].offName > a_paPathParams[i].offName)108 a_paPathParam s[j].offName += cchAdjust;114 if (a_paPathParamStates[j].offName > a_paPathParamStates[i].offName) 115 a_paPathParamStates[j].offName += cchAdjust; 109 116 } 110 117 … … 120 127 for (size_t i = 0; i < a_cQueryParams; i++) 121 128 { 122 if ((a_paQueryParams[i].fFlags & RTCRestObjectBase::kCollectionFormat_Mask) != RTCRestObjectBase::kCollectionFormat_multi) 129 if ( a_paQueryParams[i].fRequired 130 || (m_fIsSet & RT_BIT_64(a_paQueryParams[i].iBitNo)) ) 123 131 { 124 int rc = a_papQueryParamObjs[i]->toString(&strTmpVal, a_paQueryParams[i].fFlags);125 AssertRCReturn(rc, rc);132 AssertMsg(m_fIsSet & RT_BIT_64(a_paQueryParams[i].iBitNo), 133 ("Required query parameter '%s' is not set!\n", a_paQueryParams[i].pszName)); 126 134 127 rc = a_pStrQuery->appendPrintfNoThrow("%c%RMpq=%RMpq", chSep, a_paQueryParams[i].pszName, strTmpVal.c_str()); 128 AssertRCReturn(rc, rc); 135 if ( (a_paQueryParams[i].fFlags & RTCRestObjectBase::kCollectionFormat_Mask) 136 != RTCRestObjectBase::kCollectionFormat_multi) 137 { 138 int rc = a_papQueryParamObjs[i]->toString(&strTmpVal, a_paQueryParams[i].fFlags); 139 AssertRCReturn(rc, rc); 129 140 130 chSep = '&'; 131 } 132 else 133 { 134 AssertFailedReturn(VERR_NOT_IMPLEMENTED); 141 rc = a_pStrQuery->appendPrintfNoThrow("%c%RMpq=%RMpq", chSep, a_paQueryParams[i].pszName, strTmpVal.c_str()); 142 AssertRCReturn(rc, rc); 143 144 chSep = '&'; 145 } 146 else 147 { 148 AssertFailedReturn(VERR_NOT_IMPLEMENTED); 149 } 135 150 } 136 151 } … … 138 153 } 139 154 155 156 int RTCRestClientRequestBase::doHeaderParameters(RTHTTP a_hHttp, HEADERPARAMDESC const *a_paHeaderParams, 157 RTCRestObjectBase const **a_papHeaderParamObjs, size_t a_cHeaderParams) const 158 { 159 RTCString strTmpVal; 160 for (size_t i = 0; i < a_cHeaderParams; i++) 161 { 162 AssertReturn( (a_paHeaderParams[i].fFlags & RTCRestObjectBase::kCollectionFormat_Mask) 163 != RTCRestObjectBase::kCollectionFormat_multi, 164 VERR_INTERNAL_ERROR_3); 165 166 if ( a_paHeaderParams[i].fRequired 167 || (m_fIsSet & RT_BIT_64(a_paHeaderParams[i].iBitNo)) ) 168 { 169 AssertMsg(m_fIsSet & RT_BIT_64(a_paHeaderParams[i].iBitNo), 170 ("Required header parameter '%s' is not set!\n", a_paHeaderParams[i].pszName)); 171 172 int rc = a_papHeaderParamObjs[i]->toString(&strTmpVal, a_paHeaderParams[i].fFlags); 173 AssertRCReturn(rc, rc); 174 175 rc = RTHttpAppendHeader(a_hHttp, a_paHeaderParams[i].pszName, strTmpVal.c_str(), 0); 176 AssertRCReturn(rc, rc); 177 } 178 } 179 return VINF_SUCCESS; 180 } 181
Note:
See TracChangeset
for help on using the changeset viewer.