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);
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;
258 bool isUpgrade()
const;
264 static char* htdateCurrent(
char* buffer);
269 {
return _rawdata + _endOffset; }
272 static const unsigned MaxHeaderSize = 4096;
273 char _rawdata[MaxHeaderSize];
274 std::size_t _endOffset;
275 unsigned _httpVersionMajor;
276 unsigned _httpVersionMinor;
298 : _result(InProgress)
304 {
return (_result & Header) == Header; }
309 {
return (_result & Body) == Body; }
312 {
return (_result & Trailer) == Trailer; }
317 {
return (_result & Finished) == Finished; }
321 { _result |= Finished ; }
325 { _result |= Header; }
333 { _result |= Trailer; }
336 unsigned long mask()
const
340 unsigned long _result;
346 class MessageBuffer :
public std::streambuf
358 this->setp(_buffer, _buffer + _bufferSize);
363 std::size_t size()
const
364 {
return pptr() - pbase(); }
367 const char* data()
const
372 virtual int_type overflow(int_type ch);
375 virtual int_type underflow();
378 static const unsigned int BufferSize = 512;
380 std::size_t _bufferSize;
419 bool isSending()
const
420 {
return _isSending; }
423 bool isReceiving()
const
424 {
return _isReceiving; }
427 bool isFinished()
const
428 {
return _finished; }
431 MessageBuffer& buffer()
436 void setBuffer(std::streambuf& sb)
440 void setSending(
bool b)
444 void setReceiving(
bool b)
445 { _isReceiving = b; }
448 void setFinished(
bool b)
452 Http::Connection* _conn;
453 MessageHeader _header;
465 #endif // Pt_Http_Message_h
Core module.
Definition: pt-gfx-images.dox:14
bool header() const
Returns true if the header was processed.
Definition: Message.h:303
std::size_t pending() const
Returns the number of bytes pending to be written.
HTTP message with header and body.
Definition: Message.h:386
void discard()
Discards the message body.
bool body() const
Returns true if the body was processed.
Definition: Message.h:308
std::iostream & body()
Returns the body of the message.
Definition: Message.h:406
MessageProgress()
Default Constructor.
Definition: Message.h:297
const MessageHeader & header() const
Returns the header of the message.
Definition: Message.h:402
HTTP message progress.
Definition: Message.h:282
bool finished() const
Returns true if message is complete.
Definition: Message.h:316
Connection & connection()
Returns the used connection.
Definition: Message.h:394
Message(Http::Connection &conn)
Constructs with connection to use.
std::size_t available() const
Returns the number of bytes available to read.
Protects derived classes from being copied.
Definition: NonCopyable.h:54
MessageHeader & header()
Returns the header of the message.
Definition: Message.h:398
Represents a connection between a Signal/Delegate and a slot.
Definition: Connection.h:91