Commit d6d037beeb90d637a8da091177930fd789dd3c3c
1 parent
edb4f1ad
--no commit message
Showing
1 changed file
with
10 additions
and
4 deletions
Project/applications/smartcities/httpClient.c
@@ -103,9 +103,13 @@ int httpRequest(struct httpHeaders head, char* content, int content_size) | @@ -103,9 +103,13 @@ int httpRequest(struct httpHeaders head, char* content, int content_size) | ||
103 | //neocon->recv_timeout = 5000; // for 5s | 103 | //neocon->recv_timeout = 5000; // for 5s |
104 | connection_ok = netconn_recv(neocon, &netBufs); | 104 | connection_ok = netconn_recv(neocon, &netBufs); |
105 | printf("res recv= %d\r\n",connection_ok); | 105 | printf("res recv= %d\r\n",connection_ok); |
106 | - netbuf_delete(netBufs); | ||
107 | - netconn_close(neocon); | ||
108 | - netconn_delete(neocon); | 106 | + |
107 | + if(connection_ok !=0) | ||
108 | + { | ||
109 | + netbuf_delete(netBufs); | ||
110 | + netconn_close(neocon); | ||
111 | + netconn_delete(neocon); | ||
112 | + } | ||
109 | } | 113 | } |
110 | // Manage Response | 114 | // Manage Response |
111 | printf("httpRequest: Response received. Let's parse the information\r\n"); | 115 | printf("httpRequest: Response received. Let's parse the information\r\n"); |
@@ -115,7 +119,9 @@ int httpRequest(struct httpHeaders head, char* content, int content_size) | @@ -115,7 +119,9 @@ int httpRequest(struct httpHeaders head, char* content, int content_size) | ||
115 | int http_response = response2int(response); | 119 | int http_response = response2int(response); |
116 | 120 | ||
117 | // alliberem Mandela i Willy | 121 | // alliberem Mandela i Willy |
118 | - | 122 | + netbuf_delete(netBufs); |
123 | + netconn_close(neocon); | ||
124 | + netconn_delete(neocon); | ||
119 | chHeapFree(response); | 125 | chHeapFree(response); |
120 | return http_response; | 126 | return http_response; |
121 | } | 127 | } |