qhttpserverresponse.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /** HTTP response from a server.
  2. * https://github.com/azadkuh/qhttp
  3. *
  4. * @author amir zamani
  5. * @version 2.0.0
  6. * @date 2014-07-11
  7. */
  8. #ifndef QHTTPSERVER_RESPONSE_HPP
  9. #define QHTTPSERVER_RESPONSE_HPP
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #include "qhttpabstracts.hpp"
  12. ///////////////////////////////////////////////////////////////////////////////
  13. namespace qhttp {
  14. namespace server {
  15. ///////////////////////////////////////////////////////////////////////////////
  16. /** The QHttpResponse class handles sending data back to the client as a response to a request.
  17. * @sa QHttpConnection
  18. */
  19. class QHTTP_API QHttpResponse : public QHttpAbstractOutput
  20. {
  21. Q_OBJECT
  22. public:
  23. virtual ~QHttpResponse();
  24. public:
  25. /** set the response HTTP status code. @sa TStatusCode.
  26. * default value is ESTATUS_BAD_REQUEST.
  27. * @sa write()
  28. */
  29. void setStatusCode(TStatusCode code);
  30. public: // QHttpAbstractOutput methods:
  31. /** @see QHttpAbstractOutput::setVersion(). */
  32. void setVersion(const QString& versionString) override;
  33. /** @see QHttpAbstractOutput::addHeader(). */
  34. void addHeader(const QByteArray& field, const QByteArray& value) override;
  35. /** @see QHttpAbstractOutput::headers(). */
  36. THeaderHash& headers() override;
  37. /** @see QHttpAbstractOutput::write(). */
  38. void write(const QByteArray &data) override;
  39. /** @see QHttpAbstractOutput::end(). */
  40. void end(const QByteArray &data = QByteArray()) override;
  41. public:
  42. /** returns the parent QHttpConnection object. */
  43. QHttpConnection* connection() const;
  44. protected:
  45. explicit QHttpResponse(QHttpConnection*);
  46. explicit QHttpResponse(QHttpResponsePrivate&, QHttpConnection*);
  47. friend class QHttpConnectionPrivate;
  48. Q_DECLARE_PRIVATE(QHttpResponse)
  49. QScopedPointer<QHttpResponsePrivate> d_ptr;
  50. };
  51. ///////////////////////////////////////////////////////////////////////////////
  52. } // namespace server
  53. } // namespace qhttp
  54. ///////////////////////////////////////////////////////////////////////////////
  55. #endif // define QHTTPSERVER_RESPONSE_HPP