Networking
-
Base class for network task wrappers.
After a network request is made via
DBTransportClient
, a subclass ofDBTask
is returned, from which response and progress handlers can be installed, and the network response paused or cancelled.Handlers are executed on the thread specified by the
DBDelegate
instance with which theDBTask
instance is initialied (more specifically, the delegate queue that theDBDelegate
uses to execute handler code). By default, this is the main thread, which makes updating UI elements in response handlers convenient.While response handlers are not optional, they do not necessarily need to have been installed by the time the SDK has received its server response. If this is the case, completion data will be saved, and the handler will be executed with the completion data upon its installation. Downloaded content will be moved from a temporary location to the final destination when the response handler code is executed.
See moreDeclaration
Objective-C
@interface DBTask : NSObject { NSOperationQueue *_queue; }
Swift
class DBTask : NSObject
-
Dropbox RPC-style Network Task.
After an RPC network request is made via
DBTransportClient
, a subclass ofDBRpcTask
is returned, from which response and progress handlers can be installed, and the network response paused or cancelled.TResponse
is the generic representation of the route-specific result, andTError
is the generic representation of the route-specific error.Response / error deserialization is performed with this class.
See more
-
Dropbox Upload-style Network Task.
After an Upload network request is made via
DBTransportClient
, a subclass ofDBUploadTask
is returned, from which response and progress handlers can be installed, and the network response paused or cancelled.TResponse
is the generic representation of the route-specific result, andTError
is the generic representation of the route-specific error.Response / error deserialization is performed with this class.
See more
-
Dropbox Download-style Network Task (download to
NSURL
).After an Upload network request is made via
DBTransportClient
, a subclass ofDBDownloadUrlTask
is returned, from which response and progress handlers can be installed, and the network response paused or cancelled. Note, this class is returned only for download requests with anNSURL
output.TResponse
is the generic representation of the route-specific result, andTError
is the generic representation of the route-specific error.Response / error deserialization is performed with this class.
See more
-
Dropbox Download Network Task (download to
NSData
).After an Upload network request is made via
DBTransportClient
, a subclass ofDBDownloadDataTask
is returned, from which response and progress handlers can be installed, and the network response paused or cancelled. Note, this class is returned only for download requests with anNSData
output.TResponse
is the generic representation of the route-specific result, andTError
is the generic representation of the route-specific error.Response / error deserialization is performed with this class.
See more
-
Base class for generic network request error (as opposed to route-specific error).
This class is represented almost like a Stone “Union” object. As one object, it can represent a number of error “states” (see all of the values of
DBRequestErrorType
). To handle each error type, call each of theis<TAG_STATE>
methods until you determine the current tag state, then call the correspondingas<TAG_STATE>
method to return an instance of the appropriate error type.For example:
if ([dbxError isHTTPError]) { DBHttpError *httpError = [dbxError asHttpError]; } else if ([dbxError isBadInputError]) { ……..
See moreDeclaration
Objective-C
@interface DBRequestError : NSObject
Swift
class DBRequestError : NSObject
-
Http request error.
Contains relevant information regarding a failed network request. All error types except for DBClientError extend this class as children. Initialized in the event of a generic, unidentified HTTP error.
See moreDeclaration
Objective-C
@interface DBRequestHttpError : NSObject
Swift
class DBRequestHttpError : NSObject
-
Bad Input request error.
Contains relevant information regarding a failed network request. Initialized in the event of an HTTP 400 response. Extends DBRequestHttpError.
See moreDeclaration
Objective-C
@interface DBRequestBadInputError : DBRequestHttpError
Swift
class DBRequestBadInputError : DBRequestHttpError
-
Auth request error.
Contains relevant information regarding a failed network request. Initialized in the event of an HTTP 401 response. Extends DBRequestHttpError.
See moreDeclaration
Objective-C
@interface DBRequestAuthError : DBRequestHttpError
Swift
class DBRequestAuthError : DBRequestHttpError
-
Access request error.
Contains relevant information regarding a failed network request. Initialized in the event of an HTTP 403 response. Extends DBRequestHttpError.
See moreDeclaration
Objective-C
@interface DBRequestAccessError : DBRequestHttpError
Swift
class DBRequestAccessError : DBRequestHttpError
-
Rate limit request error.
Contains relevant information regarding a failed network request. Initialized in the event of an HTTP 429 response. Extends DBRequestHttpError.
See moreDeclaration
Objective-C
@interface DBRequestRateLimitError : DBRequestHttpError
Swift
class DBRequestRateLimitError : DBRequestHttpError
-
Internal Server request error.
Contains relevant information regarding a failed network request. Initialized in the event of an HTTP 500 response. Extends DBRequestHttpError.
See moreDeclaration
Objective-C
@interface DBRequestInternalServerError : DBRequestHttpError
Swift
class DBRequestInternalServerError : DBRequestHttpError
-
Client side request error.
Contains relevant information regarding a failed network request. Initialized in the event of a client-side error, like an invalid url host, or making a request when not connected to the internet.
See moreDeclaration
Objective-C
@interface DBRequestClientError : NSObject
Swift
class DBRequestClientError : NSObject
-
Configuration class for
See moreDBTransportBaseClient
.Declaration
Objective-C
@interface DBTransportBaseConfig : NSObject
Swift
class DBTransportBaseConfig : NSObject
-
Configuration class for
See moreDBTransportDefaultClient
.Declaration
Objective-C
@interface DBTransportDefaultConfig : DBTransportBaseConfig
Swift
class DBTransportDefaultConfig : DBTransportBaseConfig
-
Allows for consistent, global handling of route-specific error types, as well as general network errors.
Normally, error handling is done on a request-by-request basis, in the supplied response handler. However, it is convenient to handle some error behavior consistently, regardless of the request or the endpoint. An example of this might be implementing retry logic for all rate-limiting errors, regardless of their source. For implementing global error handling for general networking errors like rate-limiting, one of the
registerNetworkErrorResponseBlock:
methods should be used. For implementing global error handling for route-specific errors, one of theregisterRouteErrorResponseBlock:
methods should be used.For the route-specific error handling, you may supply either the direct route error type, or any type that the route error type contains as an instance field (or an instance field of an instance field, and so on).
Note
These globally supplied response handlers will be executed in place of the original request-specific response handler. At most one global response handler will be executed, with the prioirty going to the general network response handler, followed by the handler that is associated directly with the route’s error response type, followed by the handler associated with the first matching instance field.Declaration
Objective-C
@interface DBGlobalErrorResponseHandler : NSObject
Swift
class DBGlobalErrorResponseHandler : NSObject
-
The networking client for the User and Business API.
Normally, one networking client should instantiated per access token and session / background session pair. By default, all Upload-style and Download-style requests are made via a background session (except when uploading via
NSInputStream
orNSData
, or downloading toNSData
, in which case, it is not possible) and all RPC-style request are made using a foreground session.Requests are made via one of the request methods below. The request is launched, and a
DBTask
object is returned, from which response and progress handlers can be added directly. By default, these handlers are added / executed using the main thread queue and executed in a thread-safe manner (unless a custom delegate queue is supplied via theDBTransportDefaultConfig
object). An internalDBDelegate
object then retrieves the appropriate handler and executes it.While response handlers are not optional, they do not necessarily need to have been installed by the time the SDK has received its server response. If this is the case, completion data will be saved, and the handler will be executed with the completion data upon its installation. Downloaded content will be moved from a temporary location to the final destination when the response handler code is executed.
Argument serialization and deserialization is performed with this class.
See moreDeclaration
Objective-C
@interface DBTransportDefaultClient : DBTransportBaseClient <DBTransportClient>
Swift
class DBTransportDefaultClient : DBTransportBaseClient, DBTransportClient
-
The progress block to be executed in the event of a request update. The first argument is the number of bytes downloaded. The second argument is the number of total bytes downloaded. And the third argument is the number of total bytes expected to be downloaded.
Declaration
Objective-C
typedef void (^DBProgressBlock)(int64_t, int64_t, int64_t)
Swift
typealias DBProgressBlock = (Int64, Int64, Int64) -> Void
-
Special custom response block for batch upload. The first argument is a mapping of client-side NSURLs to batch upload result entries (each of which indicates the success / failure of the upload for the corresponding file). This object will be nonnull if the final call to
/upload_session/finish_batch/check
is successful. The second argument is the route-specific error from/upload_session/finish_batch/check
, which is generally not able to be handled at runtime, but instead should be used for debugging purposes. This object will be nonnull if there is a route-specific error from the call to/upload_session/finish_batch/check
. The third argument is the general request error from/upload_session/finish_batch/check
. This object will be nonnull if there is a request error from the call to/upload_session/finish_batch/check
. The fourth argument is a mapping of client-side NSURLs to general request errors, which occured during the upload of the corresponding file.Declaration
Objective-C
typedef void (^DBBatchUploadResponseBlock)( NSDictionary<NSURL *, DBFILESUploadSessionFinishBatchResultEntry *> *_Nullable, DBASYNCPollError *_Nullable, DBRequestError *_Nullable, NSDictionary<NSURL *, DBRequestError *> *_Nonnull)
Swift
typealias DBBatchUploadResponseBlock = ([URL : DBFILESUploadSessionFinishBatchResultEntry]?, DBASYNCPollError?, DBRequestError?, [URL : DBRequestError]) -> Void
-
Task storage for upload and download tasks.
Offers a convenient, thread-safe storage option for upload and download tasks so that they can be cancelled later.
See moreDeclaration
Objective-C
@interface DBTasksStorage : NSObject
Swift
class DBTasksStorage : NSObject