1 |
efrain |
1 |
/*
|
|
|
2 |
* Copyright 2017 Google
|
|
|
3 |
*
|
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
|
6 |
* You may obtain a copy of the License at
|
|
|
7 |
*
|
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
9 |
*
|
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13 |
* See the License for the specific language governing permissions and
|
|
|
14 |
* limitations under the License.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
#import <Foundation/Foundation.h>
|
|
|
18 |
|
|
|
19 |
/// Error codes in Firebase Network error domain.
|
|
|
20 |
/// Note: these error codes should never change. It would make it harder to decode the errors if
|
|
|
21 |
/// we inadvertently altered any of these codes in a future SDK version.
|
|
|
22 |
typedef NS_ENUM(NSInteger, GULNetworkErrorCode) {
|
|
|
23 |
/// Unknown error.
|
|
|
24 |
GULNetworkErrorCodeUnknown = 0,
|
|
|
25 |
/// Error occurs when the request URL is invalid.
|
|
|
26 |
GULErrorCodeNetworkInvalidURL = 1,
|
|
|
27 |
/// Error occurs when request cannot be constructed.
|
|
|
28 |
GULErrorCodeNetworkRequestCreation = 2,
|
|
|
29 |
/// Error occurs when payload cannot be compressed.
|
|
|
30 |
GULErrorCodeNetworkPayloadCompression = 3,
|
|
|
31 |
/// Error occurs when session task cannot be created.
|
|
|
32 |
GULErrorCodeNetworkSessionTaskCreation = 4,
|
|
|
33 |
/// Error occurs when there is no response.
|
|
|
34 |
GULErrorCodeNetworkInvalidResponse = 5
|
|
|
35 |
};
|
|
|
36 |
|
|
|
37 |
#pragma mark - Network constants
|
|
|
38 |
|
|
|
39 |
/// The prefix of the ID of the background session.
|
|
|
40 |
extern NSString *const kGULNetworkBackgroundSessionConfigIDPrefix;
|
|
|
41 |
|
|
|
42 |
/// The sub directory to store the files of data that is being uploaded in the background.
|
|
|
43 |
extern NSString *const kGULNetworkApplicationSupportSubdirectory;
|
|
|
44 |
|
|
|
45 |
/// Name of the temporary directory that stores files for background uploading.
|
|
|
46 |
extern NSString *const kGULNetworkTempDirectoryName;
|
|
|
47 |
|
|
|
48 |
/// The period when the temporary uploading file can stay.
|
|
|
49 |
extern const NSTimeInterval kGULNetworkTempFolderExpireTime;
|
|
|
50 |
|
|
|
51 |
/// The default network request timeout interval.
|
|
|
52 |
extern const NSTimeInterval kGULNetworkTimeOutInterval;
|
|
|
53 |
|
|
|
54 |
/// The host to check the reachability of the network.
|
|
|
55 |
extern NSString *const kGULNetworkReachabilityHost;
|
|
|
56 |
|
|
|
57 |
/// The key to get the error context of the UserInfo.
|
|
|
58 |
extern NSString *const kGULNetworkErrorContext;
|
|
|
59 |
|
|
|
60 |
#pragma mark - Network Status Code
|
|
|
61 |
|
|
|
62 |
extern const int kGULNetworkHTTPStatusOK;
|
|
|
63 |
extern const int kGULNetworkHTTPStatusNoContent;
|
|
|
64 |
extern const int kGULNetworkHTTPStatusCodeMultipleChoices;
|
|
|
65 |
extern const int kGULNetworkHTTPStatusCodeMovedPermanently;
|
|
|
66 |
extern const int kGULNetworkHTTPStatusCodeFound;
|
|
|
67 |
extern const int kGULNetworkHTTPStatusCodeNotModified;
|
|
|
68 |
extern const int kGULNetworkHTTPStatusCodeMovedTemporarily;
|
|
|
69 |
extern const int kGULNetworkHTTPStatusCodeNotFound;
|
|
|
70 |
extern const int kGULNetworkHTTPStatusCodeCannotAcceptTraffic;
|
|
|
71 |
extern const int kGULNetworkHTTPStatusCodeUnavailable;
|