A client for the SmartREST protocol from Cumulocity.

Dependencies:   SmartRest

Fork of MbedSmartRest by Vincent Wochnik

Revision:
13:e76920d5e1ec
Parent:
12:788dd934f283
Child:
14:dc3f8dd5c02b
--- a/HTTPBuffer.cpp	Wed Apr 02 12:23:46 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-#include "HTTPBuffer.h"
-#include <stdlib.h>
-#include <string.h>
-
-HTTPBuffer::HTTPBuffer()
-{
-    _rptr = _wptr = _buf = NULL;
-    bufferSize(HTTPBUFFER_INITIAL_SIZE);
-}
-
-HTTPBuffer::~HTTPBuffer()
-{
-    if (_buf != NULL)
-        free(_buf);
-}
-
-char HTTPBuffer::read()
-{
-    if (_rptr == _wptr)
-        return 0;
-    return *_rptr++;
-}
-
-uint8_t HTTPBuffer::status()
-{
-    if (_rptr == _wptr)
-        return DS_STATUS_CLOSED;
-    return DS_STATUS_OK;
-}
-
-void HTTPBuffer::writeReset()
-{
-    _rptr = _wptr = _buf;
-    bufferSize(HTTPBUFFER_INITIAL_SIZE);
-}
-
-int HTTPBuffer::write(const char* buf, size_t len)
-{
-    if (_wptr - _buf + len > _len) {
-        size_t newLen = _len;
-        while (_wptr - _buf + len > newLen)
-            newLen += HTTPBUFFER_INCREMENT;
-        bufferSize(newLen);
-    }
-    memcpy(_wptr, buf, len);
-    _wptr += len;
-}
-
-void HTTPBuffer::setDataType(const char* type)
-{
-}
-
-void HTTPBuffer::setIsChunked(bool chunked)
-{
-}
-
-void HTTPBuffer::setDataLen(size_t len)
-{
-    bufferSize(len);
-}
-
-
-void HTTPBuffer::bufferSize(size_t length)
-{
-    if (_len == length)
-        return;
-    
-    char *buf = (char*)realloc(_buf, length);
-    if (buf == NULL)
-        return;
-    
-    // set pointers
-    _wptr = buf + (_wptr - _buf);
-    _rptr = buf + (_rptr - _buf);
-    _buf = buf;
-
-    _len = length;
-}