A client for the SmartREST protocol from Cumulocity.

Dependencies:   HTTPClient SmartRest

HTTPBuffer.h

Committer:
vwochnik
Date:
2014-01-24
Revision:
3:ce2f116369bd
Parent:
2:1038411466a6
Child:
4:0eb69392686f

File content as of revision 3:ce2f116369bd:

#ifndef HTTPBUFFER_H
#define HTTPBUFFER_H

#include <stddef.h>
#include "IHTTPData.h"
#include "AbstractDataSource.h"

#define HTTPBUFFER_INITIAL_SIZE 128
#define HTTPBUFFER_INCREMENT 64

class HTTPBuffer : public HTTPDataIn, public AbstractDataSource
{
public:
    HTTPBuffer();
    ~HTTPBuffer();

    char read();
    uint8_t status();

protected:
    void writeReset();
    int write(const char* buf, size_t len);
    void setDataType(const char* type);
    void setIsChunked(bool chunked);
    void setDataLen(size_t len);
    void bufferSize(size_t length);

private:
    // buffer, write and read pointers
    char *_buf, *_wptr, *_rptr;
    size_t _len;
};

#endif