Sends 'application/json' as the content type for AerCloud compatibility
Dependents: AerCloud_C027_Sample
Fork of HTTPClient by
Diff: HTTPClient.cpp
- Revision:
- 19:c96ef4c9695c
- Parent:
- 18:277279a1891e
- Child:
- 20:b4a15dc7a299
--- a/HTTPClient.cpp Wed May 07 16:48:10 2014 +0000 +++ b/HTTPClient.cpp Mon Nov 10 22:42:11 2014 +0000 @@ -127,7 +127,7 @@ char scheme[8]; uint16_t port; char host[32]; - char path[64]; + char path[124]; //First we need to parse the url (http[s]://host[:port][/[path]]) -- HTTPS not supported (yet?) HTTPResult res = parseURL(url, scheme, sizeof(scheme), host, sizeof(host), &port, path, sizeof(path)); if(res != HTTP_OK) @@ -172,7 +172,7 @@ //Send all headers //Send default headers - DBG("Sending headers"); +// printf("Sending headers...\n"); if( pDataOut != NULL ) { if( pDataOut->getIsChunked() ) @@ -185,6 +185,10 @@ snprintf(buf, sizeof(buf), "Content-Length: %d\r\n", pDataOut->getDataLen()); ret = send(buf); CHECK_CONN_ERR(ret); + + snprintf(buf, sizeof(buf), "Accept:application/json\r\n"); + ret = send(buf); + CHECK_CONN_ERR(ret); } char type[48]; if( pDataOut->getDataType(type, 48) == HTTP_OK ) @@ -214,7 +218,7 @@ } //Close headers - DBG("Headers sent"); +// printf("Headers sent...\n"); ret = send("\r\n"); CHECK_CONN_ERR(ret); @@ -223,7 +227,7 @@ //Send data (if available) if( pDataOut != NULL ) { - DBG("Sending data"); +// printf("Sending data...\n"); while(true) { size_t writtenLen = 0; @@ -636,6 +640,7 @@ len = strlen(buf); } DBG("Trying to write %d bytes", len); + //printf("Sending %d bytes: %s\n",len, buf); size_t writtenLen = 0; if(!m_sock.is_connected())