]> gitweb.ps.run Git - matrix_esp_thesis/blobdiff - src/matrix_http_mongoose.c
verify device
[matrix_esp_thesis] / src / matrix_http_mongoose.c
index 17edbc8cdcfabe7b53e453a05b057ae71520429f..b9b2ca3e26a37bbdd3d110e16f3c84e0f9865b74 100644 (file)
@@ -56,7 +56,7 @@ MatrixHttpCallback(
         conn->dataLen = hm->body.len;\r
         conn->dataReceived = true;\r
 \r
-        printf("received[%d]:\n%.*s\n", conn->dataLen, conn->dataLen, conn->data);\r
+        //printf("received[%d]:\n%.*s\n", conn->dataLen, conn->dataLen, conn->data);\r
     }\r
     if (ev == MG_EV_CLOSE)\r
     {\r
@@ -86,7 +86,7 @@ MatrixHttpConnect(
     MatrixHttpConnection * conn =\r
         (MatrixHttpConnection *)client->httpUserData;\r
     \r
-    struct mg_connection * c =\r
+    //struct mg_connection * c =\r
         mg_http_connect(&conn->mgr, client->server, MatrixHttpCallback, client);\r
 \r
     while (! conn->connected)\r
@@ -132,6 +132,15 @@ MatrixHttpGet(
     else\r
         authorizationHeader[0] = '\0';\r
 \r
+    printf(\r
+        "GET %s HTTP/1.1\r\n"\r
+        "Host: %.*s\r\n"\r
+        "%s"\r
+        "\r\n",\r
+        url,\r
+        host.len, host.ptr,\r
+        authorizationHeader);\r
+\r
     mg_printf(conn->connection,\r
         "GET %s HTTP/1.1\r\n"\r
         "Host: %.*s\r\n"\r
@@ -173,6 +182,21 @@ MatrixHttpPost(
     else\r
         authorizationHeader[0] = '\0';\r
 \r
+    printf(\r
+            "POST %s HTTP/1.0\r\n"\r
+            "Host: %.*s\r\n"\r
+            "%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
+            host.len, host.ptr,\r
+            authorizationHeader,\r
+            strlen(requestBuffer),\r
+            requestBuffer);\r
+\r
     mg_printf(conn->connection,\r
             "POST %s HTTP/1.0\r\n"\r
             "Host: %.*s\r\n"\r
@@ -220,7 +244,9 @@ MatrixHttpPut(
     else\r
         authorizationHeader[0] = '\0';\r
 \r
-    printf("PUT %s HTTP/1.0\r\n"\r
+    \r
+    printf(\r
+            "PUT %s HTTP/1.0\r\n"\r
             "Host: %.*s\r\n"\r
             "%s"\r
             "Content-Type: application/json\r\n"\r