29#ifndef Pt_Http_Message_h
30#define Pt_Http_Message_h
32#include <Pt/Http/Api.h>
33#include <Pt/NonCopyable.h>
90 Field(
const char* f,
const char* s)
124 friend class MessageHeader;
141 {
return current.name() == it.current.
name(); }
146 {
return current.name() != it.current.
name(); }
179 if( *current.name() )
181 current.setValue( current.name() + std::strlen(current.name()) + 1 );
193 current.setName( current.value() + std::strlen(current.value()) + 1 );
216 void set(
const char* key,
const char* value);
220 void add(
const char* key,
const char* value);
228 const char*
get(
const char* key)
const;
232 bool has(
const char* key)
const
233 {
return get(key) != 0; }
237 bool isSet(
const char* key,
const char* value)
const;
252 {
return _httpVersionMajor; }
257 {
return _httpVersionMinor; }
263 _httpVersionMajor = major;
264 _httpVersionMinor = minor;
300 {
return _rawdata + _endOffset; }
303 static const unsigned MaxHeaderSize = 4096;
304 char _rawdata[MaxHeaderSize];
305 std::size_t _endOffset;
306 unsigned _httpVersionMajor;
307 unsigned _httpVersionMinor;
353 : _result(InProgress)
359 {
return (_result & Header) == Header; }
364 {
return (_result & Body) == Body; }
369 {
return (_result & Trailer) == Trailer; }
374 {
return (_result & Finished) == Finished; }
378 { _result |= Finished ; }
382 { _result |= Header; }
390 { _result |= Trailer; }
393 unsigned long mask()
const
397 unsigned long _result;
403class MessageBuffer :
public std::streambuf
415 this->setp(_buffer, _buffer + _bufferSize);
420 std::size_t size()
const
421 {
return pptr() - pbase(); }
424 const char* data()
const
429 virtual int_type overflow(int_type ch);
432 virtual int_type underflow();
435 static const unsigned int BufferSize = 512;
437 std::size_t _bufferSize;
461 friend class Connection;
493 bool isSending()
const
494 {
return _isSending; }
497 bool isReceiving()
const
498 {
return _isReceiving; }
501 bool isFinished()
const
502 {
return _finished; }
505 MessageBuffer& buffer()
510 void setBuffer(std::streambuf& sb)
514 void setSending(
bool b)
518 void setReceiving(
bool b)
519 { _isReceiving = b; }
522 void setFinished(
bool b)
526 Http::Connection* _conn;
527 MessageHeader _header;
bool body() const
Returns true if the body was processed.
Definition Message.h:363
MessageProgress()
Default Constructor.
Definition Message.h:352
bool trailer() const
Returns true if the trailer was processed.
Definition Message.h:368
bool header() const
Returns true if the header was processed.
Definition Message.h:358
bool finished() const
Returns true if message is complete.
Definition Message.h:373
const MessageHeader & header() const
Returns the header of the message.
Definition Message.h:476
void discard()
Discards the message body.
std::iostream & body()
Returns the body of the message.
Definition Message.h:480
Message(Http::Connection &conn)
Constructs with connection to use.
MessageHeader & header()
Returns the header of the message.
Definition Message.h:472
std::size_t pending() const
Returns the number of bytes pending to be written.
Connection & connection()
Returns the used connection.
Definition Message.h:468
std::size_t available() const
Returns the number of bytes available to read.
Base class that disables copy construction and assignment.
Definition NonCopyable.h:59
void fixup(const FixupInfo &fixup, T *&fixme)
Fixup references during serialization.
Definition FixupInfo.h:136
HTTP clients and servers.
Core module.
Definition Allocator.h:33