diff options
author | George Hazan <george.hazan@gmail.com> | 2024-01-05 15:54:03 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-01-05 15:54:03 +0300 |
commit | 14c4e44a0a91e1ad701d4ae3c58185d25118e64e (patch) | |
tree | 50f36035466f355c74373e757bc00b6610ce6267 /plugins/PasteIt/src | |
parent | 94667140aeb3886d22e4c1301423fe99aaf3fba4 (diff) |
Netlib:
- NETLIBHTTPHEADER & NETLIBHTTPREQUEST obsoleted;
- NETLIBHTTPREQUEST divided into MHttpRequest & MHttpResponse;
- MHttpHeaders now manager headers both for MHttpRequest & MHttpResponse;
Diffstat (limited to 'plugins/PasteIt/src')
-rw-r--r-- | plugins/PasteIt/src/PasteToWeb.cpp | 44 |
1 files changed, 8 insertions, 36 deletions
diff --git a/plugins/PasteIt/src/PasteToWeb.cpp b/plugins/PasteIt/src/PasteToWeb.cpp index 9d1ad7ac5f..5fdfc7afec 100644 --- a/plugins/PasteIt/src/PasteToWeb.cpp +++ b/plugins/PasteIt/src/PasteToWeb.cpp @@ -426,47 +426,19 @@ char *PasteToWeb::SendToWeb(char *url, std::map<std::string, std::string> &heade WideCharToMultiByte(CP_UTF8, 0, content.c_str(), -1, contentBytes, cbLen, nullptr, nullptr);
--cbLen;
- int nHeaders = 0;
- for (std::map<std::string, std::string>::iterator it = headers.begin(); it != headers.end(); ++it) {
- ++nHeaders;
- }
-
- NETLIBHTTPHEADER *httpHeaders = new NETLIBHTTPHEADER[nHeaders];
-
- NETLIBHTTPREQUEST nlhr = { 0 };
+ MHttpRequest nlhr;
nlhr.requestType = REQUEST_POST;
nlhr.flags = NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT | NLHPIF_HTTP11;
- nlhr.szUrl = url;
- nlhr.headers = httpHeaders;
- nlhr.pData = contentBytes;
- nlhr.dataLength = cbLen;
- nHeaders = 0;
- std::list<char *> mallBuf;
- for (std::map<std::string, std::string>::iterator it = headers.begin(); it != headers.end(); ++it) {
- char *b1 = new char[it->first.length() + 1];
- char *b2 = new char[it->second.length() + 1];
- mir_strncpy(b1, it->first.c_str(), it->first.length() + 1);
- mir_strncpy(b2, it->second.c_str(), it->second.length() + 1);
- httpHeaders[nHeaders].szName = b1;
- httpHeaders[nHeaders].szValue = b2;
- mallBuf.push_back(b1);
- mallBuf.push_back(b2);
- ++nHeaders;
- }
+ nlhr.m_szUrl = url;
+ nlhr.SetData(contentBytes, cbLen);
+ for (auto it : headers)
+ nlhr.AddHeader(it.first.c_str(), it.second.c_str());
char *resCont = nullptr;
- nlhr.headersCount = nHeaders;
NLHR_PTR nlhrReply(Netlib_HttpTransaction(g_hNetlibUser, &nlhr));
- if (nlhrReply != nullptr) {
- if (nlhrReply->resultCode == 200) {
- resCont = nlhrReply->pData;
- nlhrReply->pData = 0;
- }
- }
-
- delete[] httpHeaders;
- for (std::list<char *>::iterator it = mallBuf.begin(); it != mallBuf.end(); ++it)
- delete *it;
+ if (nlhrReply != nullptr)
+ if (nlhrReply->resultCode == 200)
+ resCont = nlhrReply->body.Detach();
mir_free(contentBytes);
return resCont;
|