| 147 | |
| 148 | |
| 149 | int DownloadInstance::PerformCustomRequest(const string& method, const string& url, |
| 150 | const std::unordered_map<std::string, std::string>& headers, Response& response, |
| 151 | BNDownloadInstanceInputOutputCallbacks* callbacks) |
| 152 | { |
| 153 | const char** headerKeys = new const char*[headers.size()]; |
| 154 | const char** headerValues = new const char*[headers.size()]; |
| 155 | |
| 156 | uint64_t i = 0; |
| 157 | for (auto it = headers.begin(); it != headers.end(); ++it) |
| 158 | { |
| 159 | headerKeys[i] = it->first.c_str(); |
| 160 | headerValues[i] = it->second.c_str(); |
| 161 | i++; |
| 162 | } |
| 163 | |
| 164 | BNDownloadInstanceResponse* bnResponse; |
| 165 | |
| 166 | int result = BNPerformCustomRequest( |
| 167 | m_object, method.c_str(), url.c_str(), headers.size(), headerKeys, headerValues, &bnResponse, callbacks); |
| 168 | |
| 169 | response.statusCode = bnResponse->statusCode; |
| 170 | for (uint64_t i = 0; i < bnResponse->headerCount; i++) |
| 171 | { |
| 172 | response.headers[bnResponse->headerKeys[i]] = bnResponse->headerValues[i]; |
| 173 | } |
| 174 | |
| 175 | BNFreeDownloadInstanceResponse(bnResponse); |
| 176 | |
| 177 | delete[] headerKeys; |
| 178 | delete[] headerValues; |
| 179 | |
| 180 | return result; |
| 181 | } |
| 182 | |
| 183 | |
| 184 | void DownloadInstance::DestroyInstance() |