File: GSURLSessionTaskBodySource.h

package info (click to toggle)
gnustep-base 1.28.1%2Breally1.28.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 28,008 kB
  • sloc: objc: 223,137; ansic: 35,562; sh: 184; makefile: 128; cpp: 122; xml: 32
file content (52 lines) | stat: -rw-r--r-- 1,268 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef	INCLUDED_GSURLSESSIONTASKBODYSOURCE_H
#define	INCLUDED_GSURLSESSIONTASKBODYSOURCE_H

#import "common.h"
#import "GSDispatch.h"

@class	NSFileHandle;
@class	NSInputStream;

typedef NS_ENUM(NSUInteger, GSBodySourceDataChunk) {
    GSBodySourceDataChunkData,
    // The source is depleted.
    GSBodySourceDataChunkDone,
    // Retry later to get more data.
    GSBodySourceDataChunkRetryLater,
    GSBodySourceDataChunkError
};

/*
 * A (non-blocking) source for body data.
 */
@protocol GSURLSessionTaskBodySource <NSObject>

/*
 * Get the next chunck of data.
 */
- (void) getNextChunkWithLength: (NSInteger)length
              completionHandler: (void (^)(GSBodySourceDataChunk chunk, NSData *data))completionHandler;

@end

@interface GSBodyStreamSource : NSObject <GSURLSessionTaskBodySource>

- (instancetype) initWithInputStream: (NSInputStream*)inputStream;

@end

@interface GSBodyDataSource : NSObject <GSURLSessionTaskBodySource>

- (instancetype)initWithData:(NSData *)data;

@end

@interface GSBodyFileSource : NSObject <GSURLSessionTaskBodySource>

- (instancetype) initWithFileURL: (NSURL*)fileURL
                       workQueue: (dispatch_queue_t)workQueue
            dataAvailableHandler: (void (^)(void))dataAvailableHandler;

@end

#endif