HttpRequestTaskS3E.cpp 969 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include "HttpRequestTaskS3E.h"
  2. namespace oxygine
  3. {
  4. static HttpRequestTask* createS3E()
  5. {
  6. return new HttpRequestTaskS3E;
  7. }
  8. void HttpRequestTask::init()
  9. {
  10. setCustomRequests(createS3E);
  11. }
  12. void HttpRequestTask::release()
  13. {
  14. }
  15. }
  16. HttpRequestTaskS3E::HttpRequestTaskS3E()
  17. {
  18. }
  19. void HttpRequestTaskS3E::_run()
  20. {
  21. _http._cbDone = CLOSURE(this, &HttpRequestTaskS3E::onDone);
  22. _http._cbError = CLOSURE(this, &HttpRequestTaskS3E::onError);
  23. if (_fname.empty())
  24. {
  25. if (_postData.empty())
  26. _http.get(_url);
  27. else
  28. _http.post(_url, (const char*)&_postData.front(), _postData.size());
  29. }
  30. else
  31. _http.getFile(_url, _fname);
  32. addRef();
  33. }
  34. void HttpRequestTaskS3E::onDone(MyHttp*)
  35. {
  36. std::swap(_response, _http.getBuffer());
  37. onComplete();
  38. releaseRef();
  39. }
  40. void HttpRequestTaskS3E::onError(MyHttp*)
  41. {
  42. AsyncTask::onError();
  43. releaseRef();
  44. }