| 58 | |
| 59 | |
| 60 | int DownloadInstance::PerformCustomRequestCallback(void* ctxt, const char* method, const char* url, |
| 61 | uint64_t headerCount, const char* const* headerKeys, const char* const* headerValues, |
| 62 | BNDownloadInstanceResponse** response) |
| 63 | { |
| 64 | CallbackRef<DownloadInstance> instance(ctxt); |
| 65 | unordered_map<string, string> headers; |
| 66 | for (uint64_t i = 0; i < headerCount; i++) |
| 67 | { |
| 68 | headers[headerKeys[i]] = headerValues[i]; |
| 69 | } |
| 70 | |
| 71 | Response apiResponse; |
| 72 | int status = instance->PerformCustomRequest(method, url, headers, apiResponse); |
| 73 | |
| 74 | char** keys = new char*[apiResponse.headers.size()]; |
| 75 | char** values = new char*[apiResponse.headers.size()]; |
| 76 | |
| 77 | uint64_t i = 0; |
| 78 | for (const auto& pair : apiResponse.headers) |
| 79 | { |
| 80 | keys[i] = BNAllocString(pair.first.c_str()); |
| 81 | values[i] = BNAllocString(pair.second.c_str()); |
| 82 | i++; |
| 83 | } |
| 84 | |
| 85 | *response = new BNDownloadInstanceResponse; |
| 86 | (*response)->statusCode = apiResponse.statusCode; |
| 87 | (*response)->headerCount = apiResponse.headers.size(); |
| 88 | (*response)->headerKeys = keys; |
| 89 | (*response)->headerValues = values; |
| 90 | |
| 91 | return status; |
| 92 | } |
| 93 | |
| 94 | |
| 95 | void DownloadInstance::PerformFreeResponse(void* ctxt, BNDownloadInstanceResponse* response) |
nothing calls this directly
no test coverage detected