+ "%s"\r
+ "Content-Type: application/json\r\n"\r
+ "Content-Length: %d\r\n"\r
+ "\r\n"\r
+ "%s"\r
+ "\r\n",\r
+ url,\r
+ (int)host.len, host.ptr,\r
+ authorizationHeader,\r
+ (int)strlen(requestBuffer),\r
+ requestBuffer);\r
+\r
+ hc->data = outResponseBuffer;\r
+ hc->dataCap = outResponseCap;\r
+ \r
+ while (! hc->dataReceived)\r
+ mg_mgr_poll(&hc->mgr, 1000);\r
+\r
+ return hc->dataReceived;\r
+}\r
+\r
+bool\r
+MatrixHttpPut(\r
+ MatrixHttpConnection * hc,\r
+ const char * url,\r
+ const char * requestBuffer,\r
+ char * outResponseBuffer, int outResponseCap,\r
+ bool authenticated)\r
+{\r
+ if (! hc->connected)\r
+ MatrixHttpConnect(hc);\r
+\r
+ hc->dataReceived = false;\r
+\r
+ struct mg_str host = mg_url_host(hc->host);\r
+\r
+ static char authorizationHeader[AUTHORIZATION_HEADER_LEN];\r
+ if (authenticated)\r
+ snprintf(authorizationHeader, AUTHORIZATION_HEADER_LEN,\r
+ "Authorization: Bearer %s\r\n", hc->accessToken);\r
+ else\r
+ authorizationHeader[0] = '\0';\r
+\r
+ mg_printf(hc->connection,\r
+ "PUT %s HTTP/1.0\r\n"\r
+ "Host: %.*s\r\n"\r
+ "%s"\r