diff options
Diffstat (limited to 'protocols/Discord')
-rw-r--r-- | protocols/Discord/src/http.cpp | 4 | ||||
-rw-r--r-- | protocols/Discord/src/proto.cpp | 15 |
2 files changed, 11 insertions, 8 deletions
diff --git a/protocols/Discord/src/http.cpp b/protocols/Discord/src/http.cpp index 72a6db3915..fafbfcc354 100644 --- a/protocols/Discord/src/http.cpp +++ b/protocols/Discord/src/http.cpp @@ -86,8 +86,10 @@ AsyncHttpRequest::~AsyncHttpRequest() void AsyncHttpRequest::AddHeader(LPCSTR szName, LPCSTR szValue) { for (int i = 0; i < headersCount; i++) - if (!mir_strcmp(headers[i].szName, szName)) + if (!mir_strcmp(headers[i].szName, szName)) { + replaceStr(headers[i].szValue, szValue); return; + } headers = (NETLIBHTTPHEADER*)mir_realloc(headers, sizeof(NETLIBHTTPHEADER)*(headersCount + 1)); headers[headersCount].szName = mir_strdup(szName); diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index b7ca36a546..52af24578d 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -475,11 +475,18 @@ void CDiscordProto::SendFileThread(void *param) char szRandom[16], szRandomText[33]; Utils_GetRandom(szRandom, _countof(szRandom)); bin2hex(szRandom, _countof(szRandom), szRandomText); - CMStringA szBoundary(FORMAT, "------Boundary%s", szRandomText); + CMStringA szBoundary(FORMAT, "----Boundary%s", szRandomText); if (p->wszDescr.IsEmpty()) p->wszDescr = L"blabla"; + CMStringA szUrl(FORMAT, "/channels/%lld/messages", getId(p->hContact, DB_KEY_CHANNELID)); + AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, szUrl, &CDiscordProto::OnReceiveFile); + pReq->AddHeader("Content-Type", CMStringA("multipart/form-data; boundary=" + szBoundary)); + pReq->AddHeader("Accept", "*/*"); + + szBoundary.Insert(0, "--"); + CMStringA szBody; szBody.Append(szBoundary + "\r\n"); szBody.Append("Content-Disposition: form-data; name=\"content\"\r\n\r\n"); @@ -502,12 +509,6 @@ void CDiscordProto::SendFileThread(void *param) size_t cbBytes = filelength(fileno(in)); - CMStringA szUrl(FORMAT, "/channels/%lld/messages", getId(p->hContact, DB_KEY_CHANNELID)); - AsyncHttpRequest *pReq = new AsyncHttpRequest(this, REQUEST_POST, szUrl, &CDiscordProto::OnReceiveFile); - - pReq->AddHeader("Content-Type", CMStringA("multipart/form-data; boundary=" + szBoundary)); - pReq->AddHeader("Accept", "*/*"); - szBoundary.Insert(0, "\r\n"); szBoundary.Append("--\r\n"); pReq->dataLength = int(szBody.GetLength() + szBoundary.GetLength() + cbBytes); |