summaryrefslogtreecommitdiff
path: root/plugins/CloudFile/src/http_request.h
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2017-04-25 02:26:25 +0300
committeraunsane <aunsane@gmail.com>2017-04-25 02:27:36 +0300
commit71b5d463456a90d1d0ea58c7ace0aa5e8216eec8 (patch)
tree725ff7c747d994741a9f3c70938f93e19aeb53fd /plugins/CloudFile/src/http_request.h
parent26092086b62afd9bdef93f4756ae7558ec681e9a (diff)
CloudFile: initial OneDrive implementation
Diffstat (limited to 'plugins/CloudFile/src/http_request.h')
-rw-r--r--plugins/CloudFile/src/http_request.h30
1 files changed, 16 insertions, 14 deletions
diff --git a/plugins/CloudFile/src/http_request.h b/plugins/CloudFile/src/http_request.h
index 1308ae2291..39d0d98b57 100644
--- a/plugins/CloudFile/src/http_request.h
+++ b/plugins/CloudFile/src/http_request.h
@@ -51,58 +51,60 @@ protected:
void AddBasicAuthHeader(LPCSTR szLogin, LPCSTR szPassword)
{
- char cPair[128];
+ size_t length = mir_strlen(szLogin) + mir_strlen(szPassword) + 1;
+ ptrA cPair((char*)mir_calloc(length + 1));
mir_snprintf(
cPair,
- _countof(cPair),
+ length,
"%s:%s",
szLogin,
szPassword);
- char *ePair = (char *)mir_base64_encode((BYTE*)cPair, (UINT)mir_strlen(cPair));
+ ptrA ePair(mir_base64_encode((BYTE*)(char*)cPair, length));
- char value[128];
+ length = mir_strlen(ePair) + 7;
+ char *value = (char*)mir_calloc(length + 1);
mir_snprintf(
value,
- _countof(value),
+ length,
"Basic %s",
ePair);
- mir_free(ePair);
-
headers = (NETLIBHTTPHEADER*)mir_realloc(headers, sizeof(NETLIBHTTPHEADER)*(headersCount + 1));
headers[headersCount].szName = mir_strdup("Authorization");
- headers[headersCount].szValue = mir_strdup(value);
+ headers[headersCount].szValue = value;
headersCount++;
}
void AddBearerAuthHeader(LPCSTR szValue)
{
- char value[128];
+ size_t length = mir_strlen(szValue) + 8;
+ char *value = (char*)mir_calloc(length + 1);
mir_snprintf(
value,
- _countof(value),
+ length,
"Bearer %s",
szValue);
headers = (NETLIBHTTPHEADER*)mir_realloc(headers, sizeof(NETLIBHTTPHEADER)*(headersCount + 1));
headers[headersCount].szName = mir_strdup("Authorization");
- headers[headersCount].szValue = mir_strdup(value);
+ headers[headersCount].szValue = value;
headersCount++;
}
void AddOAuthHeader(LPCSTR szValue)
{
- char value[128];
+ size_t length = mir_strlen(szValue) + 7;
+ char *value = (char*)mir_calloc(length + 1);
mir_snprintf(
value,
- _countof(value),
+ length,
"OAuth %s",
szValue);
headers = (NETLIBHTTPHEADER*)mir_realloc(headers, sizeof(NETLIBHTTPHEADER)*(headersCount + 1));
headers[headersCount].szName = mir_strdup("Authorization");
- headers[headersCount].szValue = mir_strdup(value);
+ headers[headersCount].szValue = value;
headersCount++;
}