From 7e99d4d2a1b0b0b3db2768ac0090faded5bc2455 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 30 Jun 2007 09:54:03 +0000 Subject: New class. --- src/HttpHeaderProcessor.h | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/HttpHeaderProcessor.h (limited to 'src/HttpHeaderProcessor.h') diff --git a/src/HttpHeaderProcessor.h b/src/HttpHeaderProcessor.h new file mode 100644 index 00000000..51491602 --- /dev/null +++ b/src/HttpHeaderProcessor.h @@ -0,0 +1,83 @@ +/* */ +#ifndef _D_HTTP_HEADER_PROCESSOR_H_ +#define _D_HTTP_HEADER_PROCESSOR_H_ + +#include "common.h" +#include "HttpHeader.h" +#include +#include + +class HttpHeaderProcessor { +private: + stringstream strm; + int32_t _limit; + + void checkHeaderLimit(int32_t incomingLength); + +public: + HttpHeaderProcessor():_limit(4096) {} + + ~HttpHeaderProcessor() {} + + void update(const char* data, int32_t length); + + void update(const string& data); + + /** + * Returns true if end of header is reached. + */ + bool eoh() const; + + /** + * Retruns the number of bytes beyond the end of header. + */ + int32_t getPutBackDataLength() const; + + pair getHttpStatusHeader(); + + string getHeaderString() const; + + void clear(); + + void setHeaderLimit(int32_t limit) + { + _limit = limit; + } +}; + +typedef SharedHandle HttpHeaderProcessorHandle; + +#endif // _D_HTTP_HEADER_PROCESSOR_H_ -- cgit