cppsp_cpoll.H 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 3 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. * */
  13. /*
  14. * cppsp_socketd.H
  15. *
  16. * Created on: Mar 8, 2013
  17. * Author: xaxaxa
  18. */
  19. #ifndef CPPSP_SOCKETD_H_
  20. #define CPPSP_SOCKETD_H_
  21. #include "page.H"
  22. #include <cpoll/cpoll.H>
  23. #include <string>
  24. #include "httpparser.H"
  25. using namespace std;
  26. typedef CP::String String;
  27. namespace cppsp
  28. {
  29. class CPollRequest: public Request
  30. {
  31. public:
  32. HTTPParser _parser;
  33. HTTPStream _stream;
  34. RGC::Ref<CP::Socket> s;
  35. Delegate<void(bool)> tmp_cb;
  36. int _headers_begin;
  37. bool firstLine;
  38. CPollRequest(CP::Socket& s, CP::StringPool* sp);
  39. //returns: true: request already in buffer; false: read is in progress
  40. bool readRequest(const Delegate<void(bool success)>& cb);
  41. void readPost(Delegate<void(Request&)> cb) override {
  42. parsePost(_parser.content);
  43. cb(*this);
  44. }
  45. void _beginRead();
  46. void _readCB(int i);
  47. virtual ~CPollRequest();
  48. };
  49. } /* namespace cppsp */
  50. #endif /* CPPSP_SOCKETD_H_ */