Changeset 73918 in vbox for trunk/src/VBox/Runtime/common/rest/RTCRestClientApiBase.cpp
- Timestamp:
- Aug 27, 2018 3:08:55 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/rest/RTCRestClientApiBase.cpp
r73889 r73918 60 60 } 61 61 62 63 void RTCRestClientApiBase::doCall(RTCRestClientRequestBase const &a_rRequest, RTHTTPMETHOD a_enmHttpMethod, 64 RTCRestClientResponseBase *a_pResponse) 65 { 66 /* 67 * Initialize the HTTP instance. 68 */ 69 RTHTTP hHttp = NIL_RTHTTP; 70 int rc = reinitHttpInstance(); 71 if (RT_SUCCESS(rc)) 72 { 73 hHttp = m_hHttp; 74 Assert(hHttp != NIL_RTHTTP); 75 76 /* 77 * Prepare the response side. This may install output callbacks and 78 * indicate this by clearing the ppvBody/ppvHdr variables. 79 */ 80 size_t cbHdrs = 0; 81 void *pvHdrs = NULL; 82 void **ppvHdrs = &pvHdrs; 83 84 size_t cbBody = 0; 85 void *pvBody = NULL; 86 void **ppvBody = &pvBody; 87 88 rc = a_pResponse->receivePrepare(hHttp, &ppvBody, &ppvHdrs); 89 if (RT_SUCCESS(rc)) 90 { 91 /* 92 * Prepare the request for the transmission. 93 */ 94 RTCString strExtraPath; 95 RTCString strQuery; 96 RTCString strXmitBody; 97 rc = a_rRequest.xmitPrepare(&strExtraPath, &strQuery, hHttp, &strXmitBody); 98 if (RT_SUCCESS(rc)) 99 { 100 /* 101 * Construct the full URL. 102 */ 103 RTCString strFullUrl; 104 rc = strFullUrl.assignNoThrow(m_strBasePath); 105 if (strExtraPath.isNotEmpty()) 106 { 107 if (!strExtraPath.startsWith("/") && !strFullUrl.endsWith("/") && RT_SUCCESS(rc)) 108 rc = strFullUrl.appendNoThrow('/'); 109 if (RT_SUCCESS(rc)) 110 rc = strFullUrl.appendNoThrow(strExtraPath); 111 strExtraPath.setNull(); 112 } 113 if (strQuery.isNotEmpty()) 114 { 115 if (RT_SUCCESS(rc)) 116 rc = strFullUrl.appendNoThrow('?'); 117 if (RT_SUCCESS(rc)) 118 rc = strFullUrl.appendNoThrow(strQuery); 119 strQuery.setNull(); 120 } 121 if (RT_SUCCESS(rc)) 122 { 123 /* 124 * Perform HTTP request. 125 */ 126 uint32_t uHttpStatus = 0; 127 rc = RTHttpPerform(hHttp, strFullUrl.c_str(), a_enmHttpMethod, 128 &uHttpStatus, ppvHdrs, &cbHdrs, ppvBody, &cbBody); 129 if (RT_SUCCESS(rc)) 130 { 131 a_rRequest.xmitComplete(uHttpStatus, hHttp); 132 133 /* 134 * Do response processing. 135 */ 136 a_pResponse->receiveComplete(uHttpStatus, hHttp); 137 if (pvHdrs) 138 { 139 a_pResponse->consumeHeaders((const char *)pvHdrs, cbHdrs); 140 RTHttpFreeResponse(pvHdrs); 141 } 142 if (pvBody) 143 { 144 a_pResponse->consumeBody((const char *)pvBody, cbBody); 145 RTHttpFreeResponse(pvBody); 146 } 147 a_pResponse->receiveFinal(); 148 149 return; 150 } 151 } 152 } 153 a_rRequest.xmitComplete(rc, hHttp); 154 } 155 } 156 a_pResponse->receiveComplete(rc, hHttp); 157 } 158
Note:
See TracChangeset
for help on using the changeset viewer.