HTTPClient
Fork of HTTPClient by
Revision 19:92048f7dbfda, committed 2015-08-12
- Comitter:
- ericliang
- Date:
- Wed Aug 12 02:39:24 2015 +0000
- Parent:
- 16:1f743885e7de
- Commit message:
- commit code
Changed in this revision
HTTPClient.cpp | Show annotated file Show diff for this revision Revisions of this file |
HTTPClient.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 1f743885e7de -r 92048f7dbfda HTTPClient.cpp --- a/HTTPClient.cpp Thu Aug 30 15:38:57 2012 +0000 +++ b/HTTPClient.cpp Wed Aug 12 02:39:24 2015 +0000 @@ -97,6 +97,11 @@ return m_httpResponseCode; } +int HTTPClient::setHTTPExtenHeader(const char *header ) +{ + strcpy(extendheader,header); +} + #define CHECK_CONN_ERR(ret) \ do{ \ if(ret) { \ @@ -160,7 +165,7 @@ DBG("Sending request"); char buf[CHUNK_SIZE]; const char* meth = (method==HTTP_GET)?"GET":(method==HTTP_POST)?"POST":(method==HTTP_PUT)?"PUT":(method==HTTP_DELETE)?"DELETE":""; - snprintf(buf, sizeof(buf), "%s %s HTTP/1.1\r\nHost: %s\r\n", meth, path, host); //Write request + snprintf(buf, sizeof(buf), "%s %s HTTP/1.1\r\nHost: %s\r\ndeviceKey: atYuvPIKvzJdKixe\r\n", meth, path, host); //Write request ret = send(buf); if(ret) { @@ -187,9 +192,11 @@ CHECK_CONN_ERR(ret); } char type[48]; - if( pDataOut->getDataType(type, 48) == HTTP_OK ) + //if( pDataOut->getDataType(type, 48) == HTTP_OK ) { - snprintf(buf, sizeof(buf), "Content-Type: %s\r\n", type); + //snprintf(buf, sizeof(buf), "Content-Type: %s\r\n", type); + snprintf(buf, sizeof(buf), "Content-Type: text/csv\r\n"); + ret = send(buf); CHECK_CONN_ERR(ret); }
diff -r 1f743885e7de -r 92048f7dbfda HTTPClient.h --- a/HTTPClient.h Thu Aug 30 15:38:57 2012 +0000 +++ b/HTTPClient.h Wed Aug 12 02:39:24 2015 +0000 @@ -126,6 +126,11 @@ */ int getHTTPResponseCode(); + /** Set HTTP Header + @return The HTTP 0: Fial, >0: Len + */ + int setHTTPExtenHeader(const char *header ); + private: enum HTTP_METH { @@ -145,10 +150,11 @@ TCPSocketConnection m_sock; int m_timeout; - + const char* m_basicAuthUser; const char* m_basicAuthPassword; int m_httpResponseCode; + char extendheader[256]; };