|
|
@ -375,7 +375,7 @@ REST_Request(CmdPacket *cmd) { |
|
|
|
realLen = cmdArgLen(&req); |
|
|
|
realLen = cmdArgLen(&req); |
|
|
|
if (realLen > 2048) goto fail; |
|
|
|
if (realLen > 2048) goto fail; |
|
|
|
} |
|
|
|
} |
|
|
|
DBG_REST(" bodyLen=%ld", realLen); |
|
|
|
DBG_REST(" bodyLen=%d", realLen); |
|
|
|
|
|
|
|
|
|
|
|
// we need to allocate memory for the header plus the body. First we count the length of the
|
|
|
|
// we need to allocate memory for the header plus the body. First we count the length of the
|
|
|
|
// header (including some extra counted "%s" and then we add the body length. We allocate the
|
|
|
|
// header (including some extra counted "%s" and then we add the body length. We allocate the
|
|
|
@ -394,7 +394,7 @@ REST_Request(CmdPacket *cmd) { |
|
|
|
if (client->data) os_free(client->data); |
|
|
|
if (client->data) os_free(client->data); |
|
|
|
client->data = (char*)os_zalloc(headerLen + realLen); |
|
|
|
client->data = (char*)os_zalloc(headerLen + realLen); |
|
|
|
if (client->data == NULL) goto fail; |
|
|
|
if (client->data == NULL) goto fail; |
|
|
|
DBG_REST(" totLen=%ld data=%p", headerLen + realLen, client->data); |
|
|
|
DBG_REST(" totLen=%d data=%p", headerLen + realLen, client->data); |
|
|
|
client->data_len = os_sprintf((char*)client->data, headerFmt, method, path, client->host, |
|
|
|
client->data_len = os_sprintf((char*)client->data, headerFmt, method, path, client->host, |
|
|
|
client->header, realLen, client->content_type, client->user_agent); |
|
|
|
client->header, realLen, client->content_type, client->user_agent); |
|
|
|
DBG_REST(" hdrLen=%d", client->data_len); |
|
|
|
DBG_REST(" hdrLen=%d", client->data_len); |
|
|
@ -413,7 +413,7 @@ REST_Request(CmdPacket *cmd) { |
|
|
|
espconn_regist_reconcb(client->pCon, tcpclient_recon_cb); |
|
|
|
espconn_regist_reconcb(client->pCon, tcpclient_recon_cb); |
|
|
|
|
|
|
|
|
|
|
|
if(UTILS_StrToIP((char *)client->host, &client->pCon->proto.tcp->remote_ip)) { |
|
|
|
if(UTILS_StrToIP((char *)client->host, &client->pCon->proto.tcp->remote_ip)) { |
|
|
|
DBG_REST("REST: Connect to ip %s:%ld\n",client->host, client->port); |
|
|
|
DBG_REST("REST: Connect to ip %s:%d\n",client->host, client->port); |
|
|
|
//if(client->security){
|
|
|
|
//if(client->security){
|
|
|
|
// espconn_secure_connect(client->pCon);
|
|
|
|
// espconn_secure_connect(client->pCon);
|
|
|
|
//}
|
|
|
|
//}
|
|
|
@ -421,7 +421,7 @@ REST_Request(CmdPacket *cmd) { |
|
|
|
espconn_connect(client->pCon); |
|
|
|
espconn_connect(client->pCon); |
|
|
|
//}
|
|
|
|
//}
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
DBG_REST("REST: Connect to host %s:%ld\n", client->host, client->port); |
|
|
|
DBG_REST("REST: Connect to host %s:%d\n", client->host, client->port); |
|
|
|
espconn_gethostbyname(client->pCon, (char *)client->host, &client->ip, rest_dns_found); |
|
|
|
espconn_gethostbyname(client->pCon, (char *)client->host, &client->ip, rest_dns_found); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|