HttpResponse.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /***************************************************************************
  2. * Copyright (C) 2009, 2010 by Axel Jaeger <axeljaeger@googlemail.com> *
  3. * *
  4. * This file is part of Glowworm. *
  5. * *
  6. * Glowworm is free software: you can redistribute it and/or modify *
  7. * it under the terms of the GNU General Public License as published by *
  8. * the Free Software Foundation, version 3 of the License. *
  9. * *
  10. * Glowworm is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License *
  16. * along with Glowworm. If not, see <http://www.gnu.org/licenses/>. *
  17. ***************************************************************************/
  18. #ifndef HTTPRESPONSE_H
  19. #define HTTPRESPONSE_H
  20. #include <QString>
  21. class QIODevice;
  22. class HttpResponse
  23. {
  24. public:
  25. enum HttpStatusCode {
  26. HttpOK = 200,
  27. HttpForbidden = 403,
  28. HttpFileNotFound = 404,
  29. HttpInternalServerError = 500
  30. };
  31. HttpResponse();
  32. ~HttpResponse();
  33. QIODevice* outputDevice() const;
  34. void setOutputDevice(QIODevice* device);
  35. void setStatusCode(HttpStatusCode sc);
  36. HttpStatusCode statusCode() const;
  37. void setMimeType(const QString & mimeType);
  38. QString mimeType() const;
  39. int contentLength() const;
  40. void setContentLength(int nsize);
  41. void sendHeader();
  42. bool headerSent() const;
  43. static QString statusVerbose(HttpStatusCode sc);
  44. private:
  45. QIODevice* m_outputDevice;
  46. HttpStatusCode m_statusCode;
  47. QString m_mimeType;
  48. int m_contentLength;
  49. bool m_headerSent;
  50. };
  51. #endif // HTTPRESPONSE_H