diff options
Diffstat (limited to 'source/http.c')
| -rw-r--r-- | source/http.c | 17 |
1 files changed, 5 insertions, 12 deletions
| diff --git a/source/http.c b/source/http.c index be62dce..2ac10fb 100644 --- a/source/http.c +++ b/source/http.c | |||
| @@ -146,23 +146,13 @@ int submitToApi( | |||
| 146 | WOLFSSL_CTX* sslContext, | 146 | WOLFSSL_CTX* sslContext, |
| 147 | cJSON* data, | 147 | cJSON* data, |
| 148 | const char* username, | 148 | const char* username, |
| 149 | const char* password) | 149 | const char* token) |
| 150 | { | 150 | { |
| 151 | // Form request body. | 151 | // Form request body. |
| 152 | cJSON* jRequestBody = cJSON_CreateObject(); | 152 | cJSON* jRequestBody = cJSON_CreateObject(); |
| 153 | 153 | ||
| 154 | cJSON_AddItemToObject(jRequestBody, "game", data); | 154 | cJSON_AddItemToObject(jRequestBody, "game", data); |
| 155 | 155 | ||
| 156 | cJSON_AddItemToObject( | ||
| 157 | jRequestBody, | ||
| 158 | "username", | ||
| 159 | cJSON_CreateString(username)); | ||
| 160 | |||
| 161 | cJSON_AddItemToObject( | ||
| 162 | jRequestBody, | ||
| 163 | "password", | ||
| 164 | cJSON_CreateString(password)); | ||
| 165 | |||
| 166 | const char* requestBody = cJSON_PrintUnformatted(jRequestBody); | 156 | const char* requestBody = cJSON_PrintUnformatted(jRequestBody); |
| 167 | 157 | ||
| 168 | // Gather data from endpoint URL. | 158 | // Gather data from endpoint URL. |
| @@ -304,7 +294,10 @@ int submitToApi( | |||
| 304 | r += sprintf(r, "POST %s HTTP/1.1\r\n", httpPath); | 294 | r += sprintf(r, "POST %s HTTP/1.1\r\n", httpPath); |
| 305 | r += sprintf(r, "Host: %s\r\n", httpHost); | 295 | r += sprintf(r, "Host: %s\r\n", httpHost); |
| 306 | r += sprintf(r, "Content-Type: application/json\r\n"); | 296 | r += sprintf(r, "Content-Type: application/json\r\n"); |
| 307 | r += sprintf(r, "Content-Length: %d\r\n\r\n", strlen(requestBody)); | 297 | r += sprintf(r, "Content-Length: %d\r\n", strlen(requestBody)); |
| 298 | r += sprintf(r, "X-User-Login: %s\r\n", username); | ||
| 299 | r += sprintf(r, "X-User-Token: %s\r\n", token); | ||
| 300 | r += sprintf(r, "\r\n"); | ||
| 308 | 301 | ||
| 309 | int result = tcpWrite( | 302 | int result = tcpWrite( |
| 310 | secure, | 303 | secure, |
