From de63d1467471156b66a5ff78fe69125a1487a543 Mon Sep 17 00:00:00 2001 From: James Yang Date: Thu, 16 May 2024 15:35:27 -0700 Subject: [PATCH] Add downloadContentHost for download style request in DBTransportBaseHostnameConfig (#381) --- .../Networking/DBTransportBaseHostnameConfig.h | 4 +++- .../Networking/DBTransportBaseHostnameConfig.m | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Source/ObjectiveDropboxOfficial/Shared/Handwritten/Networking/DBTransportBaseHostnameConfig.h b/Source/ObjectiveDropboxOfficial/Shared/Handwritten/Networking/DBTransportBaseHostnameConfig.h index fa9887f6e..ff77dedd8 100644 --- a/Source/ObjectiveDropboxOfficial/Shared/Handwritten/Networking/DBTransportBaseHostnameConfig.h +++ b/Source/ObjectiveDropboxOfficial/Shared/Handwritten/Networking/DBTransportBaseHostnameConfig.h @@ -30,6 +30,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly, copy) NSString *meta; @property (nonatomic, readonly, copy) NSString *api; @property (nonatomic, readonly, copy) NSString *content; +@property (nonatomic, readonly, copy) NSString *downloadContent; @property (nonatomic, readonly, copy) NSString *notify; /// @@ -45,11 +46,12 @@ NS_ASSUME_NONNULL_BEGIN /// @param meta the hostname to metaserver /// @param api the hostname to api server /// @param content the hostname to content server +/// @param downloadContent the hostname to content server for download style /// @param notify the hostname to notify server /// /// @return An initialized instance with the provided hostname configuration /// -- (instancetype)initWithMeta:(NSString *)meta api:(NSString *)api content:(NSString *)content notify:(NSString *)notify; +- (instancetype)initWithMeta:(NSString *)meta api:(NSString *)api content:(NSString *)content downloadContent:(NSString *)downloadContent notify:(NSString *)notify; /// /// Returns the prefix to use for API calls to the given route type. diff --git a/Source/ObjectiveDropboxOfficial/Shared/Handwritten/Networking/DBTransportBaseHostnameConfig.m b/Source/ObjectiveDropboxOfficial/Shared/Handwritten/Networking/DBTransportBaseHostnameConfig.m index 0812fe117..7772d423e 100644 --- a/Source/ObjectiveDropboxOfficial/Shared/Handwritten/Networking/DBTransportBaseHostnameConfig.m +++ b/Source/ObjectiveDropboxOfficial/Shared/Handwritten/Networking/DBTransportBaseHostnameConfig.m @@ -41,17 +41,32 @@ - (instancetype)initWithMeta:(NSString *)meta _meta = meta; _api = api; _content = content; + _downloadContent = content; _notify = notify; } return self; } +- (instancetype)initWithMeta:(NSString *)meta + api:(NSString *)api + content:(NSString *)content + downloadContent:(NSString *)downloadContent + notify:(NSString *)notify { + self = [self initWithMeta:meta api:api content:content notify:notify]; + _downloadContent = downloadContent; + return self; +} + - (nullable NSString *)apiV2PrefixWithRoute:(DBRoute *)route { switch (route.host) { case DBRouteHostApi: return [NSString stringWithFormat:@"https://%@/2", _api]; case DBRouteHostContent: - return [NSString stringWithFormat:@"https://%@/2", _content]; + if ([route.attrs[@"style"] isEqualToString:@"download"]) { + return [NSString stringWithFormat:@"https://%@/2", _downloadContent]; + } else { + return [NSString stringWithFormat:@"https://%@/2", _content]; + } case DBRouteHostNotify: return [NSString stringWithFormat:@"https://%@/2", _notify]; case DBRouteHostUnknown: