2 * Copyright 2017 Google
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #import <Foundation/Foundation.h>
18 #import <GoogleUtilities/GULLogger.h>
20 /// Error codes in Firebase Network error domain.
21 /// Note: these error codes should never change. It would make it harder to decode the errors if
22 /// we inadvertently altered any of these codes in a future SDK version.
23 typedef NS_ENUM(NSInteger, GULNetworkErrorCode) {
25 GULNetworkErrorCodeUnknown = 0,
26 /// Error occurs when the request URL is invalid.
27 GULErrorCodeNetworkInvalidURL = 1,
28 /// Error occurs when request cannot be constructed.
29 GULErrorCodeNetworkRequestCreation = 2,
30 /// Error occurs when payload cannot be compressed.
31 GULErrorCodeNetworkPayloadCompression = 3,
32 /// Error occurs when session task cannot be created.
33 GULErrorCodeNetworkSessionTaskCreation = 4,
34 /// Error occurs when there is no response.
35 GULErrorCodeNetworkInvalidResponse = 5
38 #pragma mark - Network constants
40 /// The prefix of the ID of the background session.
41 extern NSString *const kGULNetworkBackgroundSessionConfigIDPrefix;
43 /// The sub directory to store the files of data that is being uploaded in the background.
44 extern NSString *const kGULNetworkApplicationSupportSubdirectory;
46 /// Name of the temporary directory that stores files for background uploading.
47 extern NSString *const kGULNetworkTempDirectoryName;
49 /// The period when the temporary uploading file can stay.
50 extern const NSTimeInterval kGULNetworkTempFolderExpireTime;
52 /// The default network request timeout interval.
53 extern const NSTimeInterval kGULNetworkTimeOutInterval;
55 /// The host to check the reachability of the network.
56 extern NSString *const kGULNetworkReachabilityHost;
58 /// The key to get the error context of the UserInfo.
59 extern NSString *const kGULNetworkErrorContext;
61 #pragma mark - Network Status Code
63 extern const int kGULNetworkHTTPStatusOK;
64 extern const int kGULNetworkHTTPStatusNoContent;
65 extern const int kGULNetworkHTTPStatusCodeMultipleChoices;
66 extern const int kGULNetworkHTTPStatusCodeMovedPermanently;
67 extern const int kGULNetworkHTTPStatusCodeFound;
68 extern const int kGULNetworkHTTPStatusCodeNotModified;
69 extern const int kGULNetworkHTTPStatusCodeMovedTemporarily;
70 extern const int kGULNetworkHTTPStatusCodeNotFound;
71 extern const int kGULNetworkHTTPStatusCodeCannotAcceptTraffic;
72 extern const int kGULNetworkHTTPStatusCodeUnavailable;
74 #pragma mark - Error Domain
76 extern NSString *const kGULNetworkErrorDomain;
78 /// The logger service for GULNetwork.
79 extern GULLoggerService kGULLoggerNetwork;