Dependents:   SimpleLCDClock readCard2Twitter_http AnalogClock_StepperMotor_NTP ServoCamV1

services/http/client/data/HttpStream.h

Committer:
donatien
Date:
2010-05-24
Revision:
0:a2dd0ba6cd2d
Child:
1:7043cc0db03c

File content as of revision 0:a2dd0ba6cd2d:

#ifndef HTTP_STREAM_H
#define HTTP_STREAM_H

#include "../HttpData.h"
#include "mbed.h"

typedef uint8_t byte;

class HttpStream : public HttpData //Streaming buf
{
public:
  HttpStream();
  virtual ~HttpStream();
  
  void readNext(byte* buf, int size);
  
  bool readable();
  
  int readLen();
      
protected:
  virtual int read(char* buf, int len);
  virtual int write(const char* buf, int len);
  
  virtual string getDataType(); //Internet media type for Content-Type header
  virtual void setDataType(const string& type); //Internet media type from Content-Type header

  virtual bool getIsChunked(); //For Transfer-Encoding header
  virtual void setIsChunked(bool chunked); //From Transfer-Encoding header
  
  virtual int getDataLen(); //For Content-Length header
  virtual void setDataLen(int len); //From Content-Length header, or if the transfer is chunked, next chunk length
  
private:
  byte* m_buf;
  int m_size; //Capacity
  int m_len; //Length
};

#endif