A client for the SmartREST protocol from Cumulocity.

Dependencies:   SmartRest

Fork of MbedSmartRest by Vincent Wochnik

HTTPResponseFilter.h

Committer:
vwochnik
Date:
2014-05-26
Revision:
18:f76f9ae79195
Parent:
15:0ce90c525e7a

File content as of revision 18:f76f9ae79195:

#ifndef HTTPRESPONSEFILTER_H
#define HTTPRESPONSEFILTER_H

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

#define RESPF_STATE_INIT 0
#define RESPF_STATE_READ_STATUS 1
#define RESPF_STATE_READ_HEADERS 2

/**
 * Reads and evaluates a HTTP response.
 * The read() and status() methods allow access to the response content
 * without HTTP headers.
 */
class HTTPResponseFilter : public AbstractDataSource
{
public:
    HTTPResponseFilter(AbstractDataSource& source);
    ~HTTPResponseFilter();
    
    char read();
    uint8_t status();

    uint16_t readStatus();
    bool skipHeaders();
    
    void reset();

private:
    AbstractDataSource& _source;
    uint8_t _state;
    size_t _length, _read;
};

#endif