qhttpserverrequest.hpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /** HTTP request which is received by the 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_REQUEST_HPP
  9. #define QHTTPSERVER_REQUEST_HPP
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #include "qhttpabstracts.hpp"
  12. #include <QUrl>
  13. ///////////////////////////////////////////////////////////////////////////////
  14. namespace qhttp {
  15. namespace server {
  16. ///////////////////////////////////////////////////////////////////////////////
  17. /** The QHttpRequest class represents the header and body data sent by the client.
  18. * The class is <b>read-only</b>.
  19. * @sa QHttpConnection
  20. */
  21. class QHTTP_API QHttpRequest : public QHttpAbstractInput
  22. {
  23. Q_OBJECT
  24. public:
  25. virtual ~QHttpRequest();
  26. public: // QHttpAbstractInput methods:
  27. /** @see QHttpAbstractInput::headers(). */
  28. const THeaderHash& headers() const override;
  29. /** @see QHttpAbstractInput::httpVersion(). */
  30. const QString& httpVersion() const override;
  31. /** @see QHttpAbstractInput::isSuccessful(). */
  32. bool isSuccessful() const override;
  33. /** @see QHttpAbstractInput::collectData(). */
  34. void collectData(int atMost = -1) override;
  35. /** @see QHttpAbstractInput::collectedData(). */
  36. const QByteArray& collectedData()const override;
  37. public:
  38. /** The method used for the request. */
  39. THttpMethod method() const ;
  40. /** Returns the method string for the request.
  41. * @note This will plainly transform the enum into a string HTTP_GET -> "HTTP_GET". */
  42. const QString methodString() const;
  43. /** The complete URL for the request.
  44. * This includes the path and query string. @sa path(). */
  45. const QUrl& url() const;
  46. /** IP Address of the client in dotted decimal format. */
  47. const QString& remoteAddress() const;
  48. /** Outbound connection port for the client. */
  49. quint16 remotePort() const;
  50. /** returns the parent QHttpConnection object. */
  51. QHttpConnection* connection() const;
  52. protected:
  53. explicit QHttpRequest(QHttpConnection*);
  54. explicit QHttpRequest(QHttpRequestPrivate&, QHttpConnection*);
  55. friend class QHttpConnectionPrivate;
  56. Q_DECLARE_PRIVATE(QHttpRequest)
  57. QScopedPointer<QHttpRequestPrivate> d_ptr;
  58. };
  59. ///////////////////////////////////////////////////////////////////////////////
  60. } // namespace server
  61. } // namespace qhttp
  62. ///////////////////////////////////////////////////////////////////////////////
  63. #endif // define QHTTPSERVER_REQUEST_HPP