llcorehttpresponse.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * @file llcorehttpresponse.cpp
  3. * @brief
  4. *
  5. * $LicenseInfo:firstyear=2012&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2012, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "linden_common.h"
  27. #include "llcorehttpresponse.h"
  28. #include "llcorebufferarray.h"
  29. namespace LLCore
  30. {
  31. HttpResponse::HttpResponse()
  32. : LLCoreInt::RefCounted(true),
  33. mReplyOffset(0U),
  34. mReplyLength(0U),
  35. mReplyFullLength(0U),
  36. mBufferArray(NULL),
  37. mRetries(0U),
  38. m503Retries(0U)
  39. {
  40. }
  41. HttpResponse::~HttpResponse()
  42. {
  43. setBody(NULL);
  44. }
  45. void HttpResponse::setBody(BufferArray* ba)
  46. {
  47. if (mBufferArray != ba)
  48. {
  49. if (mBufferArray)
  50. {
  51. mBufferArray->release();
  52. }
  53. if (ba)
  54. {
  55. ba->addRef();
  56. }
  57. mBufferArray = ba;
  58. }
  59. }
  60. size_t HttpResponse::getBodySize() const
  61. {
  62. return mBufferArray ? mBufferArray->size() : 0;
  63. }
  64. } // End namespace LLCore