Changeset 74013 in vbox
- Timestamp:
- Aug 31, 2018 8:57:59 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/restbase.h
r74009 r74013 404 404 /** Safe copy assignment method. */ 405 405 int assignCopy(RTCRestBool const &a_rThat); 406 /** Assign value and clear null indicator. */ 407 void assignValue(bool a_fValue); 406 408 407 409 /* Overridden methods: */ … … 434 436 RTCRestInt64(RTCRestInt64 const &a_rThat); 435 437 /** From value constructor. */ 436 RTCRestInt64(int64_t iValue);438 RTCRestInt64(int64_t a_iValue); 437 439 /** Destructor. */ 438 440 virtual ~RTCRestInt64(); … … 441 443 /** Safe copy assignment method. */ 442 444 int assignCopy(RTCRestInt64 const &a_rThat); 445 /** Assign value and clear null indicator. */ 446 void assignValue(int64_t a_iValue); 443 447 444 448 /* Overridden methods: */ … … 478 482 /** Safe copy assignment method. */ 479 483 int assignCopy(RTCRestInt32 const &a_rThat); 484 /** Assign value and clear null indicator. */ 485 void assignValue(int32_t a_iValue); 480 486 481 487 /* Overridden methods: */ … … 515 521 /** Safe copy assignment method. */ 516 522 int assignCopy(RTCRestInt16 const &a_rThat); 523 /** Assign value and clear null indicator. */ 524 void assignValue(int16_t a_iValue); 517 525 518 526 /* Overridden methods: */ … … 552 560 /** Safe copy assignment method. */ 553 561 int assignCopy(RTCRestDouble const &a_rThat); 562 /** Assign value and clear null indicator. */ 563 void assignValue(double a_rdValue); 554 564 555 565 /* Overridden methods: */ -
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.