- Timestamp:
- Aug 31, 2018 8:57:59 PM (6 years ago)
- Location:
- trunk/src/VBox/Runtime/common/rest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/rest/RTCRestClientApiBase.cpp
r74009 r74013 68 68 LogFlow(("doCall: %s %s\n", a_pszMethod, RTHttpMethodName(a_enmHttpMethod))); 69 69 70 /*71 * Reset the response object, allowing reuse of such.72 */73 a_pResponse->reset();74 70 75 71 /* 76 * Initialize the HTTP instance. 72 * Reset the response object (allowing reuse of such) and check the request 73 * object for assignment errors. 77 74 */ 75 int rc; 78 76 RTHTTP hHttp = NIL_RTHTTP; 79 int rc = reinitHttpInstance(); 80 if (RT_SUCCESS(rc)) 77 78 a_pResponse->reset(); 79 if (!a_rRequest.hasAssignmentErrors()) 81 80 { 82 hHttp = m_hHttp;83 Assert(hHttp != NIL_RTHTTP);84 85 81 /* 86 * Prepare the response side. This may install output callbacks and 87 * indicate this by clearing the ppvBody/ppvHdr variables. 82 * Initialize the HTTP instance. 88 83 */ 89 size_t cbHdrs = 0; 90 void *pvHdrs = NULL; 91 void **ppvHdrs = &pvHdrs; 92 93 size_t cbBody = 0; 94 void *pvBody = NULL; 95 void **ppvBody = &pvBody; 96 97 rc = a_pResponse->receivePrepare(hHttp, &ppvBody, &ppvHdrs); 84 rc = reinitHttpInstance(); 98 85 if (RT_SUCCESS(rc)) 99 86 { 87 hHttp = m_hHttp; 88 Assert(hHttp != NIL_RTHTTP); 89 100 90 /* 101 * Prepare the request for the transmission. 91 * Prepare the response side. This may install output callbacks and 92 * indicate this by clearing the ppvBody/ppvHdr variables. 102 93 */ 103 RTCString strExtraPath; 104 RTCString strQuery; 105 RTCString strXmitBody; 106 rc = a_rRequest.xmitPrepare(&strExtraPath, &strQuery, hHttp, &strXmitBody); 94 size_t cbHdrs = 0; 95 void *pvHdrs = NULL; 96 void **ppvHdrs = &pvHdrs; 97 98 size_t cbBody = 0; 99 void *pvBody = NULL; 100 void **ppvBody = &pvBody; 101 102 rc = a_pResponse->receivePrepare(hHttp, &ppvBody, &ppvHdrs); 107 103 if (RT_SUCCESS(rc)) 108 104 { 109 105 /* 110 * Construct the full URL.106 * Prepare the request for the transmission. 111 107 */ 112 RTCString strFullUrl; 113 rc = strFullUrl.assignNoThrow(m_strBasePath); 114 if (strExtraPath.isNotEmpty()) 115 { 116 if (!strExtraPath.startsWith("/") && !strFullUrl.endsWith("/") && RT_SUCCESS(rc)) 117 rc = strFullUrl.appendNoThrow('/'); 118 if (RT_SUCCESS(rc)) 119 rc = strFullUrl.appendNoThrow(strExtraPath); 120 strExtraPath.setNull(); 121 } 122 if (strQuery.isNotEmpty()) 123 { 124 Assert(strQuery.startsWith("?")); 125 rc = strFullUrl.appendNoThrow(strQuery); 126 strQuery.setNull(); 127 } 108 RTCString strExtraPath; 109 RTCString strQuery; 110 RTCString strXmitBody; 111 rc = a_rRequest.xmitPrepare(&strExtraPath, &strQuery, hHttp, &strXmitBody); 128 112 if (RT_SUCCESS(rc)) 129 113 { 130 114 /* 131 * Perform HTTP request.115 * Construct the full URL. 132 116 */ 133 uint32_t uHttpStatus = 0; 134 rc = RTHttpPerform(hHttp, strFullUrl.c_str(), a_enmHttpMethod, strXmitBody.c_str(), strXmitBody.length(), 135 &uHttpStatus, ppvHdrs, &cbHdrs, ppvBody, &cbBody); 117 RTCString strFullUrl; 118 rc = strFullUrl.assignNoThrow(m_strBasePath); 119 if (strExtraPath.isNotEmpty()) 120 { 121 if (!strExtraPath.startsWith("/") && !strFullUrl.endsWith("/") && RT_SUCCESS(rc)) 122 rc = strFullUrl.appendNoThrow('/'); 123 if (RT_SUCCESS(rc)) 124 rc = strFullUrl.appendNoThrow(strExtraPath); 125 strExtraPath.setNull(); 126 } 127 if (strQuery.isNotEmpty()) 128 { 129 Assert(strQuery.startsWith("?")); 130 rc = strFullUrl.appendNoThrow(strQuery); 131 strQuery.setNull(); 132 } 136 133 if (RT_SUCCESS(rc)) 137 134 { 138 a_rRequest.xmitComplete(uHttpStatus, hHttp); 135 /* 136 * Perform HTTP request. 137 */ 138 uint32_t uHttpStatus = 0; 139 rc = RTHttpPerform(hHttp, strFullUrl.c_str(), a_enmHttpMethod, strXmitBody.c_str(), strXmitBody.length(), 140 &uHttpStatus, ppvHdrs, &cbHdrs, ppvBody, &cbBody); 141 if (RT_SUCCESS(rc)) 142 { 143 a_rRequest.xmitComplete(uHttpStatus, hHttp); 139 144 140 /* 141 * Do response processing. 142 */ 143 a_pResponse->receiveComplete(uHttpStatus, hHttp); 144 if (pvHdrs) 145 { 146 a_pResponse->consumeHeaders((const char *)pvHdrs, cbHdrs); 147 RTHttpFreeResponse(pvHdrs); 145 /* 146 * Do response processing. 147 */ 148 a_pResponse->receiveComplete(uHttpStatus, hHttp); 149 if (pvHdrs) 150 { 151 a_pResponse->consumeHeaders((const char *)pvHdrs, cbHdrs); 152 RTHttpFreeResponse(pvHdrs); 153 } 154 if (pvBody) 155 { 156 a_pResponse->consumeBody((const char *)pvBody, cbBody); 157 RTHttpFreeResponse(pvBody); 158 } 159 a_pResponse->receiveFinal(); 160 161 return a_pResponse->getStatus(); 148 162 } 149 if (pvBody)150 {151 a_pResponse->consumeBody((const char *)pvBody, cbBody);152 RTHttpFreeResponse(pvBody);153 }154 a_pResponse->receiveFinal();155 156 return a_pResponse->getStatus();157 163 } 158 164 } 165 a_rRequest.xmitComplete(rc, hHttp); 159 166 } 160 a_rRequest.xmitComplete(rc, hHttp);161 167 } 162 168 } 169 else 170 rc = VERR_NO_MEMORY; 171 163 172 a_pResponse->receiveComplete(rc, hHttp); 164 173 RT_NOREF_PV(a_pszMethod); -
trunk/src/VBox/Runtime/common/rest/rest-primary-object-types.cpp
r74008 r74013 176 176 177 177 178 void RTCRestBool::assignValue(bool a_fValue) 179 { 180 m_fValue = a_fValue; 181 m_fNullIndicator = false; 182 } 183 184 178 185 int RTCRestBool::resetToDefault() 179 186 { … … 336 343 337 344 345 void RTCRestInt64::assignValue(int64_t a_iValue) 346 { 347 m_iValue = a_iValue; 348 m_fNullIndicator = false; 349 } 350 351 338 352 int RTCRestInt64::resetToDefault() 339 353 { … … 491 505 m_fNullIndicator = false; 492 506 return VINF_SUCCESS; 507 } 508 509 510 void RTCRestInt32::assignValue(int32_t a_iValue) 511 { 512 m_iValue = a_iValue; 513 m_fNullIndicator = false; 493 514 } 494 515 … … 642 663 643 664 665 void RTCRestInt16::assignValue(int16_t a_iValue) 666 { 667 m_iValue = a_iValue; 668 m_fNullIndicator = false; 669 } 670 671 644 672 int RTCRestInt16::resetToDefault() 645 673 { … … 797 825 798 826 827 void RTCRestDouble::assignValue(double a_rdValue) 828 { 829 m_rdValue = a_rdValue; 830 m_fNullIndicator = false; 831 } 832 833 799 834 int RTCRestDouble::resetToDefault() 800 835 {
Note:
See TracChangeset
for help on using the changeset viewer.