Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d5ead1

Browse files
authored
Merge pull request #332 from pubnub/fix/ce-2974
Added new error category PNRequestURITooLongCategory
2 parents 599db1f + 2714aac commit 3d5ead1

9 files changed

Lines changed: 71 additions & 14 deletions

File tree

Example/PubNub Example.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@
358358
);
359359
runOnlyForDeploymentPostprocessing = 0;
360360
shellPath = /bin/sh;
361-
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
361+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
362362
showEnvVarsInLog = 0;
363363
};
364364
EB32FAA5552E101751C805CC /* [CP] Copy Pods Resources */ = {
@@ -388,7 +388,7 @@
388388
);
389389
runOnlyForDeploymentPostprocessing = 0;
390390
shellPath = /bin/sh;
391-
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
391+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
392392
showEnvVarsInLog = 0;
393393
};
394394
/* End PBXShellScriptBuildPhase section */

Example/PubNub Mac Example/AppDelegate.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,17 @@ - (void)handleErrorStatus:(PNErrorStatus *)status {
610610
NSLog(@"This may happen when you connect to a public WiFi Hotspot that requires you to auth via your web browser first,");
611611
NSLog(@"or if there is a proxy somewhere returning an HTML access denied error, or if there was an intermittent server issue.");
612612
}
613-
613+
else if (status.category == PNRequestURITooLongCategory) {
614+
if (status.operation == PNSubscribeOperation) {
615+
616+
NSLog(@"Too many channels has been passed to subscribe API.");
617+
}
618+
else {
619+
620+
NSLog(@"Depending from used API this error may mean what to big message has been publish for publish API,");
621+
NSLog(@" or too many channels has been passed to stream controller at once.");
622+
}
623+
}
614624
else if (status.category == PNTimeoutCategory) {
615625

616626
NSLog(@"For whatever reason, the request timed out. Temporary connectivity issues, etc.");

Example/PubNub/PNAppDelegate.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,17 @@ - (void)handleErrorStatus:(PNErrorStatus *)status {
611611
NSLog(@"This may happen when you connect to a public WiFi Hotspot that requires you to auth via your web browser first,");
612612
NSLog(@"or if there is a proxy somewhere returning an HTML access denied error, or if there was an intermittent server issue.");
613613
}
614-
614+
else if (status.category == PNRequestURITooLongCategory) {
615+
if (status.operation == PNSubscribeOperation) {
616+
617+
NSLog(@"Too many channels has been passed to subscribe API.");
618+
}
619+
else {
620+
621+
NSLog(@"Depending from used API this error may mean what to big message has been publish for publish API,");
622+
NSLog(@" or too many channels has been passed to stream controller at once.");
623+
}
624+
}
615625
else if (status.category == PNTimeoutCategory) {
616626

617627
NSLog(@"For whatever reason, the request timed out. Temporary connectivity issues, etc.");

PubNub/Core/PubNub+Core.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ - (void)notifyDeprecatedAPI {
639639
[deprecation appendString:@"- Deprecated: PNConfiguration.shouldStripMobilePayload property.-\n"
640640
"When set to YES SDK automatically stripped out original message\nfrompayload which combined message"
641641
" and push notification payloads.\n\n"];
642-
[deprecation appendString:@"!!! To disable this warning set shouldStripMobilePayload to NO.\n\n"];
642+
[deprecation appendString:@"!!! To disable this warning set stripMobilePayload to NO.\n\n"];
643643
[deprecation appendString:@"This deprecation may affect application in case if it used\npublish API "
644644
"to send messages along with push notification payloads.\nProperty completely will be deprecated "
645645
"with next 'major' SDK update.\n\n"];

PubNub/Data/Managers/PNSubscriber.m

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,15 @@ typedef NS_OPTIONS(NSUInteger, PNSubscriberState) {
7777
7878
@since 4.0
7979
*/
80-
PNMalformedFilterExpressionErrorSubscriberState
80+
PNMalformedFilterExpressionErrorSubscriberState,
81+
82+
/**
83+
@brief State set at the moment when client received response with 414 status code for
84+
subscribe/unsubscribe requests.
85+
86+
@since 4.6.2
87+
*/
88+
PNPNRequestURITooLongErrorSubscriberState
8189
};
8290

8391

@@ -744,6 +752,16 @@ - (void)updateStateTo:(PNSubscriberState)state withStatus:(PNSubscribeStatus *)s
744752
shouldHandleTransition = YES;
745753
category = PNMalformedFilterExpressionCategory;
746754
}
755+
// Check whether transit to 'request URI too long' state.
756+
else if (targetState == PNPNRequestURITooLongErrorSubscriberState) {
757+
758+
// Change state to 'Unexpected disconnect'
759+
targetState = PNDisconnectedUnexpectedlySubscriberState;
760+
761+
self.mayRequireSubscriptionRestore = NO;
762+
shouldHandleTransition = YES;
763+
category = PNRequestURITooLongCategory;
764+
}
747765

748766
// Check whether allowed state transition has been issued or not.
749767
if (shouldHandleTransition) {
@@ -1201,10 +1219,12 @@ - (void)handleFailedSubscriptionStatus:(PNSubscribeStatus *)status {
12011219
if (status.category == PNAccessDeniedCategory || status.category == PNTimeoutCategory ||
12021220
status.category == PNMalformedFilterExpressionCategory ||
12031221
status.category == PNMalformedResponseCategory ||
1222+
status.category == PNRequestURITooLongCategory ||
12041223
status.category == PNTLSConnectionFailedCategory) {
12051224

12061225
__weak __typeof(self) weakSelf = self;
1207-
((PNStatus *)status).automaticallyRetry = (status.category != PNMalformedFilterExpressionCategory);
1226+
((PNStatus *)status).automaticallyRetry = (status.category != PNMalformedFilterExpressionCategory &&
1227+
status.category != PNRequestURITooLongCategory);
12081228
((PNStatus *)status).retryCancelBlock = ^{
12091229

12101230
DDLogAPICall(weakSelf.client.logger, @"<PubNub::API> Cancel retry");
@@ -1217,8 +1237,13 @@ - (void)handleFailedSubscriptionStatus:(PNSubscribeStatus *)status {
12171237

12181238
subscriberState = PNMalformedFilterExpressionErrorSubscriberState;
12191239
}
1240+
else if(status.category == PNRequestURITooLongCategory) {
1241+
1242+
subscriberState = PNPNRequestURITooLongErrorSubscriberState;
1243+
}
12201244
if (status.category != PNAccessDeniedCategory &&
1221-
status.category != PNMalformedFilterExpressionCategory) {
1245+
status.category != PNMalformedFilterExpressionCategory &&
1246+
status.category != PNRequestURITooLongCategory) {
12221247

12231248
subscriberState = PNDisconnectedUnexpectedlySubscriberState;
12241249
[(PNStatus *)status updateCategory:PNUnexpectedDisconnectCategory];

PubNub/Data/Service Objects/PNStatus.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ - (PNStatusCategory)categoryTypeFromStatusCode:(NSInteger)statusCode {
224224

225225
PNStatusCategory category = PNUnknownCategory;
226226
if (statusCode == 403) { category = PNAccessDeniedCategory; }
227+
else if (statusCode == 414) { category = PNRequestURITooLongCategory; }
227228
else if (statusCode == 481) { category = PNMalformedFilterExpressionCategory; }
228229

229230
return category;

PubNub/Misc/PNPrivateStructures.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static NSString * const PNOperationStatusClasses[23] = {
9393
9494
@since 4.0
9595
*/
96-
static NSString * const PNStatusCategoryStrings[17] = {
96+
static NSString * const PNStatusCategoryStrings[18] = {
9797
[PNUnknownCategory] = @"Unknown",
9898
[PNAcknowledgmentCategory] = @"Acknowledgment",
9999
[PNAccessDeniedCategory] = @"Access Denied",
@@ -106,6 +106,7 @@ static NSString * const PNStatusCategoryStrings[17] = {
106106
[PNUnexpectedDisconnectCategory] = @"Unexpected Disconnect",
107107
[PNCancelledCategory] = @"Cancelled",
108108
[PNBadRequestCategory] = @"Bad Request",
109+
[PNRequestURITooLongCategory] = @"Request-URI Too Long",
109110
[PNMalformedFilterExpressionCategory] = @"Malformed Filter Expression",
110111
[PNMalformedResponseCategory] = @"Malformed Response",
111112
[PNDecryptionErrorCategory] = @"Decryption Error",

PubNub/Misc/PNStructures.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,15 +540,25 @@ typedef NS_ENUM(NSInteger, PNStatusCategory) {
540540
@since 4.0
541541
*/
542542
PNCancelledCategory,
543-
543+
544544
/**
545545
@brief Status is used to notify what API request from client is malformed.
546546
@discussion In case if this status arrive, it is better to print out status object debug
547547
description and contact [email protected]
548-
548+
549549
@since 4.0
550550
*/
551551
PNBadRequestCategory,
552+
553+
/**
554+
@brief Status is used to notify what composed API request has too many data in it.
555+
@discussion In case if this status arrive, depending from used API it mean what too many data has been
556+
passed to it. For example for publish it may mean what too big message has been sent. For
557+
subscription/unsubscription API it may mean what too many channels has been passed to API.
558+
559+
@since 4.6.2
560+
*/
561+
PNRequestURITooLongCategory,
552562

553563
/**
554564
@brief Status is used to notify what client has been configured with malformed filtering expression.

Tests/PubNub Tests.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@
954954
);
955955
runOnlyForDeploymentPostprocessing = 0;
956956
shellPath = /bin/sh;
957-
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
957+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
958958
showEnvVarsInLog = 0;
959959
};
960960
3685D383FB18DAB09018651A /* [CP] Embed Pods Frameworks */ = {
@@ -1069,7 +1069,7 @@
10691069
);
10701070
runOnlyForDeploymentPostprocessing = 0;
10711071
shellPath = /bin/sh;
1072-
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
1072+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
10731073
showEnvVarsInLog = 0;
10741074
};
10751075
A2F495B02C8AA374F188D16F /* [CP] Check Pods Manifest.lock */ = {
@@ -1084,7 +1084,7 @@
10841084
);
10851085
runOnlyForDeploymentPostprocessing = 0;
10861086
shellPath = /bin/sh;
1087-
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
1087+
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
10881088
showEnvVarsInLog = 0;
10891089
};
10901090
A479618187CD493DD13E855B /* [CP] Copy Pods Resources */ = {

0 commit comments

Comments
 (0)