GCDWebServerDataRequest.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. Copyright (c) 2012-2015, Pierre-Olivier Latour
  3. All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. * Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. * Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the distribution.
  11. * The name of Pierre-Olivier Latour may not be used to endorse
  12. or promote products derived from this software without specific
  13. prior written permission.
  14. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  15. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  16. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17. DISCLAIMED. IN NO EVENT SHALL PIERRE-OLIVIER LATOUR BE LIABLE FOR ANY
  18. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  19. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  20. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  23. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #import "GCDWebServerRequest.h"
  26. /**
  27. * The GCDWebServerDataRequest subclass of GCDWebServerRequest stores the body
  28. * of the HTTP request in memory.
  29. */
  30. @interface GCDWebServerDataRequest : GCDWebServerRequest
  31. /**
  32. * Returns the data for the request body.
  33. */
  34. @property(nonatomic, readonly) NSData* data;
  35. @end
  36. @interface GCDWebServerDataRequest (Extensions)
  37. /**
  38. * Returns the data for the request body interpreted as text. If the content
  39. * type of the body is not a text one, or if an error occurs, nil is returned.
  40. *
  41. * The text encoding used to interpret the data is extracted from the
  42. * "Content-Type" header or defaults to UTF-8.
  43. */
  44. @property(nonatomic, readonly) NSString* text;
  45. /**
  46. * Returns the data for the request body interpreted as a JSON object. If the
  47. * content type of the body is not JSON, or if an error occurs, nil is returned.
  48. */
  49. @property(nonatomic, readonly) id jsonObject;
  50. @end