|
@@ -34,6 +34,19 @@
|
|
|
*/
|
|
|
typedef NSData* (^GCDWebServerStreamBlock)(NSError** error);
|
|
|
|
|
|
+/**
|
|
|
+ * The GCDWebServerAsyncStreamBlock works like the GCDWebServerStreamBlock
|
|
|
+ * except the streamed data can be returned at a later time allowing for
|
|
|
+ * truly asynchronous generation of the data.
|
|
|
+ *
|
|
|
+ * The block must return empty NSData when done or nil on error and set the
|
|
|
+ * "error" argument which is guaranteed to be non-NULL.
|
|
|
+ *
|
|
|
+ * The block must eventually call "completionBlock" passing the streamed data
|
|
|
+ * if any and the error if applicable.
|
|
|
+ */
|
|
|
+typedef void (^GCDWebServerAsyncStreamBlock)(GCDWebServerBodyReaderCompletionBlock completionBlock);
|
|
|
+
|
|
|
/**
|
|
|
* The GCDWebServerStreamedResponse subclass of GCDWebServerResponse streams
|
|
|
* the body of the HTTP response using a GCD block.
|
|
@@ -46,8 +59,18 @@ typedef NSData* (^GCDWebServerStreamBlock)(NSError** error);
|
|
|
+ (instancetype)responseWithContentType:(NSString*)type streamBlock:(GCDWebServerStreamBlock)block;
|
|
|
|
|
|
/**
|
|
|
- * This method is the designated initializer for the class.
|
|
|
+ * Creates a response with async streamed data and a given content type.
|
|
|
+ */
|
|
|
++ (instancetype)responseWithContentType:(NSString*)type asyncStreamBlock:(GCDWebServerAsyncStreamBlock)block;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Initializes a response with streamed data and a given content type.
|
|
|
*/
|
|
|
- (instancetype)initWithContentType:(NSString*)type streamBlock:(GCDWebServerStreamBlock)block;
|
|
|
|
|
|
+/**
|
|
|
+ * This method is the designated initializer for the class.
|
|
|
+ */
|
|
|
+- (instancetype)initWithContentType:(NSString*)type asyncStreamBlock:(GCDWebServerAsyncStreamBlock)block;
|
|
|
+
|
|
|
@end
|