qhttpclientrequest.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /** HTTP request from a client.
  2. * https://github.com/azadkuh/qhttp
  3. *
  4. * @author amir zamani
  5. * @version 2.0.0
  6. * @date 2014-07-11
  7. */
  8. #ifndef QHTTPCLIENT_REQUEST_HPP
  9. #define QHTTPCLIENT_REQUEST_HPP
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #include "qhttpabstracts.hpp"
  12. #include <QUrl>
  13. ///////////////////////////////////////////////////////////////////////////////
  14. namespace qhttp {
  15. namespace client {
  16. ///////////////////////////////////////////////////////////////////////////////
  17. /** a class for building a new HTTP request.
  18. * the life cycle of this class and the memory management is handled by QHttpClient.
  19. * @sa QHttpClient
  20. */
  21. class QHTTP_API QHttpRequest : public QHttpAbstractOutput
  22. {
  23. Q_OBJECT
  24. public:
  25. virtual ~QHttpRequest();
  26. public: // QHttpAbstractOutput methods:
  27. /** @see QHttpAbstractOutput::setVersion(). */
  28. void setVersion(const QString& versionString) override;
  29. /** @see QHttpAbstractOutput::addHeader(). */
  30. void addHeader(const QByteArray& field, const QByteArray& value) override;
  31. /** @see QHttpAbstractOutput::headers(). */
  32. THeaderHash& headers() override;
  33. /** @see QHttpAbstractOutput::write(). */
  34. void write(const QByteArray &data) override;
  35. /** @see QHttpAbstractOutput::end(). */
  36. void end(const QByteArray &data = QByteArray()) override;
  37. public:
  38. /** returns parent QHttpClient object. */
  39. QHttpClient* connection() const;
  40. protected:
  41. explicit QHttpRequest(QHttpClient*);
  42. explicit QHttpRequest(QHttpRequestPrivate&, QHttpClient*);
  43. friend class QHttpClient;
  44. Q_DECLARE_PRIVATE(QHttpRequest)
  45. QScopedPointer<QHttpRequestPrivate> d_ptr;
  46. };
  47. ///////////////////////////////////////////////////////////////////////////////
  48. } // namespace client
  49. } // namespace qhttp
  50. ///////////////////////////////////////////////////////////////////////////////
  51. #endif // define QHTTPCLIENT_REQUEST_HPP