AFHTTPRequestOperationManager+Synchronous.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #import <AFNetworking/AFHTTPRequestOperationManager.h>
  2. /**
  3. A minimal category which extends AFHTTPRequestOperationManager to support
  4. synchronous requests.
  5. **This category is for AFNetworking 2.x.**
  6. */
  7. @interface AFHTTPRequestOperationManager (Synchronous)
  8. /**
  9. Creates and runs an AFHTTPRequestOperation with a GET request.
  10. @param URLString The URL string used to create the request URL.
  11. @param parameters The parameters to be encoded according to the client
  12. request serializer.
  13. @param operationPtr The address at which a pointer to the
  14. AFHTTPRequestOperation is placed.
  15. @param outError The address at which a pointer to an error object is placed
  16. when the request operation finishes unsucessfully.
  17. @return The response object created by the client response serializer.
  18. */
  19. - (id)syncGET:(NSString *)URLString
  20. parameters:(NSDictionary *)parameters
  21. operation:(AFHTTPRequestOperation *__autoreleasing *)operationPtr
  22. error:(NSError *__autoreleasing *)outError;
  23. /**
  24. Creates and runs an AFHTTPRequestOperation with a POST request.
  25. @param URLString The URL string used to create the request URL.
  26. @param parameters The parameters to be encoded according to the client
  27. request serializer.
  28. @param operationPtr The address at which a pointer to the
  29. AFHTTPRequestOperation is placed.
  30. @param outError The address at which a pointer to an error object is placed
  31. when the request operation finishes unsucessfully.
  32. @return The response object created by the client response serializer.
  33. */
  34. - (id)syncPOST:(NSString *)URLString
  35. parameters:(NSDictionary *)parameters
  36. operation:(AFHTTPRequestOperation *__autoreleasing *) operationPtr
  37. error:(NSError *__autoreleasing *) outError;
  38. /**
  39. Creates and runs an AFHTTPRequestOperation with a PUT request.
  40. @param URLString The URL string used to create the request URL.
  41. @param parameters The parameters to be encoded according to the client
  42. request serializer.
  43. @param operationPtr The address at which a pointer to the
  44. AFHTTPRequestOperation is placed.
  45. @param outError The address at which a pointer to an error object is placed
  46. when the request operation finishes unsucessfully.
  47. @return The response object created by the client response serializer.
  48. */
  49. - (id)syncPUT:(NSString *)URLString
  50. parameters:(NSDictionary *)parameters
  51. operation:(AFHTTPRequestOperation *__autoreleasing *) operationPtr
  52. error:(NSError *__autoreleasing *) outError;
  53. /**
  54. Creates and runs an AFHTTPRequestOperation with a DELETE request.
  55. @param URLString The URL string used to create the request URL.
  56. @param parameters The parameters to be encoded according to the client
  57. request serializer.
  58. @param operationPtr The address at which a pointer to the
  59. AFHTTPRequestOperation is placed.
  60. @param outError The address at which a pointer to an error object is placed
  61. when the request operation finishes unsucessfully.
  62. @return The response object created by the client response serializer.
  63. */
  64. - (id)syncDELETE:(NSString *)URLString
  65. parameters:(NSDictionary *)parameters
  66. operation:(AFHTTPRequestOperation *__autoreleasing *) operationPtr
  67. error:(NSError *__autoreleasing *) outError;
  68. /**
  69. Creates and runs an AFHTTPRequestOperation with a PATCH request.
  70. @param URLString The URL string used to create the request URL.
  71. @param parameters The parameters to be encoded according to the client
  72. request serializer.
  73. @param operationPtr The address at which a pointer to the
  74. AFHTTPRequestOperation is placed.
  75. @param outError The address at which a pointer to an error object is placed
  76. when the request operation finishes unsucessfully.
  77. @return The response object created by the client response serializer.
  78. */
  79. - (id)syncPATCH:(NSString *)URLString
  80. parameters:(NSDictionary *)parameters
  81. operation:(AFHTTPRequestOperation *__autoreleasing *) operationPtr
  82. error:(NSError *__autoreleasing *) outError;
  83. /**
  84. Enqueue an AFHTTPRequestOperation with a request for the given HTTP method.
  85. @param method The HTTP method.
  86. @param URLString The URL string used to create the request URL.
  87. @param parameters The parameters to be encoded and set in the request HTTP body.
  88. @param operationPtr The address at which a pointer to the
  89. AFHTTPRequestOperation is placed.
  90. @param outError The address at which a pointer to an error object is placed
  91. when the request operation finishes unsucessfully.
  92. @return The object created from the response data of the request.
  93. */
  94. - (id)synchronouslyPerformMethod:(NSString *)method
  95. URLString:(NSString *)URLString
  96. parameters:(NSDictionary *)parameters
  97. operation:(AFHTTPRequestOperation *__autoreleasing *)operationPtr
  98. error:(NSError *__autoreleasing *)outError;
  99. @end