mbed.org implementation of the abstract SmartREST library for the Cumulocity Platform SmartREST protocol.

Dependents:   MbedSmartRestMain MbedSmartRestMain

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HTTPResponseFilter.h Source File

HTTPResponseFilter.h

00001 /*
00002  * HTTPResponseFilter.h
00003  *
00004  * Created on: Feb 1, 2013
00005  * * Authors: Vincent Wochnik <v.wochnik@gmail.com>
00006  *
00007  * Copyright (c) 2013 Cumulocity GmbH
00008  *
00009  * Permission is hereby granted, free of charge, to any person obtaining
00010  * a copy of this software and associated documentation files (the
00011  * "Software"), to deal in the Software without restriction, including
00012  * without limitation the rights to use, copy, modify, merge, publish,
00013  * distribute, sublicense, and/or sell copies of the Software, and to
00014  * permit persons to whom the Software is furnished to do so, subject to
00015  * the following conditions:
00016  *
00017  * The above copyright notice and this permission notice shall be
00018  * included in all copies or substantial portions of the Software.
00019  *
00020  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00021  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00022  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00023  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00024  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00025  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00026  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00027  */
00028 
00029 #ifndef HTTPRESPONSEFILTER_H
00030 #define HTTPRESPONSEFILTER_H
00031 
00032 #include <stddef.h>
00033 #include "AbstractDataSource.h"
00034 
00035 #define RESPF_STATE_INIT 0
00036 #define RESPF_STATE_READ_STATUS 1
00037 #define RESPF_STATE_READ_HEADERS 2
00038 
00039 /**
00040  * Reads and evaluates a HTTP response.
00041  * The read() and status() methods allow access to the response content
00042  * without HTTP headers.
00043  */
00044 class HTTPResponseFilter : public AbstractDataSource
00045 {
00046 public:
00047     HTTPResponseFilter(AbstractDataSource& source);
00048     ~HTTPResponseFilter();
00049     
00050     char read();
00051     uint8_t status();
00052 
00053     uint16_t readStatus();
00054     bool skipHeaders();
00055     
00056     void reset();
00057 
00058 private:
00059     AbstractDataSource& _source;
00060     uint8_t _state;
00061     size_t _length, _read;
00062 };
00063 
00064 #endif