TreeFrogFramework  2.8
thttpheader.h
Go to the documentation of this file.
1 #pragma once
2 #include <TCookie>
3 #include <TInternetMessageHeader>
4 
5 
7 public:
8  THttpHeader();
9  THttpHeader(const THttpHeader &other);
10  THttpHeader(const QByteArray &str);
11  virtual ~THttpHeader() { }
12 
13  THttpHeader &operator=(const THttpHeader &other);
14  virtual QByteArray toByteArray() const;
15  virtual int majorVersion() const { return _majorVersion; }
16  virtual int minorVersion() const { return _minorVersion; }
17 
18 protected:
19  int _majorVersion {1};
20  int _minorVersion {1};
21 };
22 
23 
25 public:
28  THttpRequestHeader(const QByteArray &str);
30 
31  const QByteArray &method() const { return _reqMethod; }
32  const QByteArray &path() const { return _reqUri; }
33  void setRequest(const QByteArray &method, const QByteArray &path, int majorVer = 1, int minorVer = 1);
34  QByteArray cookie(const QString &name) const;
35  QList<TCookie> cookies() const;
36  virtual QByteArray toByteArray() const;
37 
38 private:
39  QByteArray _reqMethod;
40  QByteArray _reqUri;
41 };
42 
43 
45 public:
48  THttpResponseHeader(const QByteArray &str);
49 
50  int statusCode() const { return _statusCode; }
51  void setStatusLine(int code, const QByteArray &text = QByteArray(), int majorVer = 1, int minorVer = 1);
52  virtual QByteArray toByteArray() const;
54  void clear();
55 
56 private:
57  int _statusCode {0};
58  QByteArray _reasonPhrase;
59 };
60 
The THttpHeader class is the abstract base class of request or response header information for HTTP.
Definition: thttpheader.h:6
virtual int minorVersion() const
Returns the minor protocol-version of the HTTP header.
Definition: thttpheader.h:16
virtual ~THttpHeader()
Definition: thttpheader.h:11
virtual int majorVersion() const
Returns the major protocol-version of the HTTP header.
Definition: thttpheader.h:15
The THttpRequestHeader class contains request header information for HTTP.
Definition: thttpheader.h:24
const QByteArray & method() const
Returns the method of the HTTP request header.
Definition: thttpheader.h:31
const QByteArray & path() const
Returns the request-URI of the HTTP request header.
Definition: thttpheader.h:32
The THttpResponseHeader class contains response header information for HTTP.
Definition: thttpheader.h:44
int statusCode() const
Returns the status code of the HTTP response header.
Definition: thttpheader.h:50
The TInternetMessageHeader class contains internet message headers.
Definition: tinternetmessageheader.h:9
TInternetMessageHeader & operator=(const TInternetMessageHeader &other)
Assigns other to this internet message header and returns a reference to this header.
Definition: tinternetmessageheader.cpp:299
void clear()
Removes all the entries from the Internet message header.
Definition: tinternetmessageheader.cpp:289
virtual QByteArray toByteArray() const
Sets the value of the header field Date to utc as Coordinated Universal Time.
Definition: tinternetmessageheader.cpp:193
#define T_CORE_EXPORT
Definition: tdeclexport.h:28