This repository was archived by the owner on Sep 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathSPTDataLoaderRequestResponseHandler.h
More file actions
120 lines (103 loc) · 4.02 KB
/
SPTDataLoaderRequestResponseHandler.h
File metadata and controls
120 lines (103 loc) · 4.02 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
Copyright Spotify AB.
SPDX-License-Identifier: Apache-2.0
*/
#import <Foundation/Foundation.h>
@class SPTDataLoaderRequest;
@class SPTDataLoaderResponse;
@protocol SPTDataLoaderRequestResponseHandler;
NS_ASSUME_NONNULL_BEGIN
/**
A private delegate API for the creator of SPTDataLoader to use for routing requests through a user authentication
layer
*/
@protocol SPTDataLoaderRequestResponseHandlerDelegate <NSObject>
/**
Performs a request
@param requestResponseHandler The object that can perform requests and responses
@param request The object describing the request to perform
*/
- (void)requestResponseHandler:(id<SPTDataLoaderRequestResponseHandler>)requestResponseHandler
performRequest:(SPTDataLoaderRequest *)request;
/**
Cancels a request
@param requestResponseHandler The object that can perform cancels
@param request The object describing the request to cancel
*/
- (void)requestResponseHandler:(id<SPTDataLoaderRequestResponseHandler>)requestResponseHandler
cancelRequest:(SPTDataLoaderRequest *)request;
@optional
/**
Delegate a successfully authorised request
@param requestResponseHandler The handler that successfully authorised the request
@param request The request that contains the authorisation headers
*/
- (void)requestResponseHandler:(id<SPTDataLoaderRequestResponseHandler>)requestResponseHandler
authorisedRequest:(SPTDataLoaderRequest *)request;
/**
Delegate a failed authorisation attempt for a request
@param requestResponseHandler The handler that failed to authorise the request
@param request The request whose authorisation failed
@param error The object describing the failure in the authorisation request
*/
- (void)requestResponseHandler:(id<SPTDataLoaderRequestResponseHandler>)requestResponseHandler
failedToAuthoriseRequest:(SPTDataLoaderRequest *)request
error:(NSError *)error;
@end
@protocol SPTDataLoaderRequestResponseHandler <NSObject>
/**
The object to delegate performing requests to
*/
@property (nonatomic, weak, readonly, nullable) id<SPTDataLoaderRequestResponseHandlerDelegate> requestResponseHandlerDelegate;
/**
Call when a response successfully completed
@param response The response that successfully completed
*/
- (void)successfulResponse:(SPTDataLoaderResponse *)response;
/**
Call when a response failed to complete
@param response The response that failed to complete
*/
- (void)failedResponse:(SPTDataLoaderResponse *)response;
/**
Call when a request becomes cancelled
@param request The request that was cancelled
*/
- (void)cancelledRequest:(SPTDataLoaderRequest *)request;
/**
Called when a chunk is received
@param data The data received by the request
@param response The response the chunk is received for
*/
- (void)receivedDataChunk:(NSData *)data forResponse:(SPTDataLoaderResponse *)response;
/**
Called when the headers for a response are received
@param response The response containing the initial information (such as headers)
*/
- (void)receivedInitialResponse:(SPTDataLoaderResponse *)response;
/**
Called when a request with waitsForConnectivity enters the waiting state
@param request The request that is waiting
*/
- (void)requestIsWaitingForConnectivity:(SPTDataLoaderRequest *)request;
/**
Called when a request using the @c bodyStream property encounters some sort of redirection that invalidates
the initially provided input stream.
@param completionHandler The completion handler that is to be called with the new input stream.
@param request The request that needs a new input stream.
*/
- (void)needsNewBodyStream:(void (^)(NSInputStream *))completionHandler
forRequest:(SPTDataLoaderRequest *)request;
@optional
/**
Whether the request needs authorisation according to this handler
@param request The request that may need authorisation
*/
- (BOOL)shouldAuthoriseRequest:(SPTDataLoaderRequest *)request;
/**
Authorise a request
@param request The request to be authorise
*/
- (void)authoriseRequest:(SPTDataLoaderRequest *)request;
@end
NS_ASSUME_NONNULL_END