A HTTP Client for the mbed networking libraries, with PUT method
Fork of HTTPClient by
Diff: HTTPClient.cpp
- Revision:
- 14:0463c8425d73
- Parent:
- 13:be61104f4e91
diff -r be61104f4e91 -r 0463c8425d73 HTTPClient.cpp --- a/HTTPClient.cpp Sun Aug 05 16:12:10 2012 +0000 +++ b/HTTPClient.cpp Tue Aug 14 11:54:13 2012 +0000 @@ -82,6 +82,11 @@ return connect(url, HTTP_POST, (IHTTPDataOut*)&dataOut, pDataIn, timeout); } +HTTPResult HTTPClient::put(const char* url, const IHTTPDataOut& dataOut, IHTTPDataIn* pDataIn, int timeout /*= HTTP_CLIENT_DEFAULT_TIMEOUT*/) //Blocking +{ + return connect(url, HTTP_PUT, (IHTTPDataOut*)&dataOut, pDataIn, timeout); +} + int HTTPClient::getHTTPResponseCode() { return m_httpResponseCode; @@ -143,7 +148,7 @@ //Send request DBG("Sending request"); char buf[CHUNK_SIZE]; - const char* meth = (method==HTTP_GET)?"GET":(method==HTTP_POST)?"POST":""; + const char* meth = (method==HTTP_GET)?"GET":(method==HTTP_POST)?"POST":(method==HTTP_PUT)?"PUT":""; snprintf(buf, sizeof(buf), "%s %s HTTP/1.1\r\nHost: %s\r\n", meth, path, host); //Write request ret = send(buf); if(ret) @@ -157,7 +162,7 @@ //Send default headers DBG("Sending headers"); - if( (method == HTTP_POST) && (pDataOut != NULL) ) + if( (method == HTTP_POST || method == HTTP_PUT) && (pDataOut != NULL) ) { if( pDataOut->getIsChunked() ) { @@ -187,7 +192,7 @@ size_t trfLen; //Send data (if POST) - if( (method == HTTP_POST) && (pDataOut != NULL) ) + if( (method == HTTP_POST || method == HTTP_PUT) && (pDataOut != NULL) ) { DBG("Sending data"); while(true)