29 #ifndef Pt_Http_Message_h
30 #define Pt_Http_Message_h
32 #include <Pt/Http/Api.h>
33 #include <Pt/NonCopyable.h>
65 Field(
const char* f,
const char* s)
116 {
return current.name() == it.current.
name(); }
121 {
return current.name() != it.current.
name(); }
154 if( *current.name() )
156 current.
setValue( current.name() + std::strlen(current.name()) + 1 );
168 current.setName( current.value() + std::strlen(current.value()) + 1 );
191 void set(
const char* key,
const char* value);
195 void add(
const char* key,
const char* value);
199 void remove(
const char* key);
203 const char*
get(
const char* key)
const;
207 bool has(
const char* key)
const
208 {
return get(key) != 0; }
212 bool isSet(
const char* key,
const char* value)
const;
227 {
return _httpVersionMajor; }
232 {
return _httpVersionMinor; }
238 _httpVersionMajor = major;
239 _httpVersionMinor = minor;
244 bool isChunked()
const;
248 std::size_t contentLength()
const;
252 bool isKeepAlive()
const;
260 static char* htdateCurrent(
char* buffer);
265 {
return _rawdata + _endOffset; }
268 static const unsigned MaxHeaderSize = 4096;
269 char _rawdata[MaxHeaderSize];
270 std::size_t _endOffset;
271 unsigned _httpVersionMajor;
272 unsigned _httpVersionMinor;
294 : _result(InProgress)
300 {
return (_result & Header) == Header; }
305 {
return (_result & Body) == Body; }
308 {
return (_result & Trailer) == Trailer; }
313 {
return (_result & Finished) == Finished; }
317 { _result |= Finished ; }
321 { _result |= Header; }
329 { _result |= Trailer; }
332 unsigned long mask()
const
336 unsigned long _result;
342 class MessageBuffer :
public std::streambuf
354 this->setp(_buffer, _buffer + _bufferSize);
359 std::size_t size()
const
360 {
return pptr() - pbase(); }
363 const char* data()
const
368 virtual int_type overflow(int_type ch);
371 virtual int_type underflow();
374 static const unsigned int BufferSize = 512;
376 std::size_t _bufferSize;
387 explicit Message(Http::Connection& conn);
405 bool isSending()
const
406 {
return _isSending; }
409 bool isReceiving()
const
410 {
return _isReceiving; }
413 bool isFinished()
const
414 {
return _finished; }
420 MessageBuffer& buffer()
425 void setBuffer(std::streambuf& sb)
429 void setSending(
bool b)
433 void setReceiving(
bool b)
434 { _isReceiving = b; }
437 void setFinished(
bool b)
441 Http::Connection* _conn;
442 MessageHeader _header;
454 #endif // Pt_Http_Message_h
HTTP message progress.
Definition: Message.h:277
bool header() const
Returns true if the header was processed.
Definition: Message.h:299
Protects derived classes from being copied.
Definition: NonCopyable.h:54
const MessageHeader & header() const
Returns the header of the message.
Definition: Message.h:397
HTTP message with header and body.
Definition: Message.h:381
bool body() const
Returns true if the body was processed.
Definition: Message.h:304
MessageProgress()
Default Constructor.
Definition: Message.h:293
Represents a connection between a Signal/Delegate and a slot.
Definition: Connection.h:90
std::iostream & body()
Returns the body of the message.
Definition: Message.h:401
MessageHeader & header()
Returns the header of the message.
Definition: Message.h:393
bool finished() const
Returns true if message is complete.
Definition: Message.h:312