Skip to content

Commit

Permalink
feat: Add idempotency (#1790)
Browse files Browse the repository at this point in the history
  • Loading branch information
dplewis authored Jun 17, 2024
1 parent ceb4623 commit dcdf457
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern NSString *const PFCommandHeaderNameAppBuildVersion;
extern NSString *const PFCommandHeaderNameAppDisplayVersion;
extern NSString *const PFCommandHeaderNameOSVersion;
extern NSString *const PFCommandHeaderNameSessionToken;
extern NSString *const PFCommandHeaderNameRequestId;

///--------------------------------------
#pragma mark - HTTP Method Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
NSString *const PFCommandHeaderNameAppDisplayVersion = @"X-Parse-App-Display-Version";
NSString *const PFCommandHeaderNameOSVersion = @"X-Parse-OS-Version";
NSString *const PFCommandHeaderNameSessionToken = @"X-Parse-Session-Token";
NSString *const PFCommandHeaderNameRequestId = @"X-Parse-Request-Id";

NSString *const PFCommandParameterNameMethodOverride = @"_method";
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ + (NSDictionary *)defaultURLRequestHeadersForApplicationId:(NSString *)applicati
if (clientKey) {
mutableHeaders[PFCommandHeaderNameClientKey] = clientKey;
}

mutableHeaders[PFCommandHeaderNameRequestId] = [[NSUUID UUID] UUIDString];
mutableHeaders[PFCommandHeaderNameClientVersion] = [versionPrefix stringByAppendingString:PARSE_VERSION];
mutableHeaders[PFCommandHeaderNameOSVersion] = [PFDevice currentDevice].operatingSystemFullVersion;

Expand Down
4 changes: 4 additions & 0 deletions Parse/Parse/Source/PFConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ typedef NS_ENUM(NSInteger, PFErrorCode) {
Application has exceeded its request limit.
*/
kPFErrorRequestLimitExceeded = 155,
/**
Request was a duplicate and has been discarded due to idempotency rules.
*/
kPFErrorDuplicateRequest = 159,
/**
Invalid event name.
*/
Expand Down
1 change: 1 addition & 0 deletions Parse/Tests/Unit/CommandURLRequestConstructorTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ - (void)testDefaultURLRequestHeaders {
XCTAssertNotNil(headers[PFCommandHeaderNameOSVersion]);
XCTAssertNotNil(headers[PFCommandHeaderNameAppBuildVersion]);
XCTAssertNotNil(headers[PFCommandHeaderNameAppDisplayVersion]);
XCTAssertNotNil(headers[PFCommandHeaderNameRequestId]);
}

- (void)testBailOnEncodingError {
Expand Down

0 comments on commit dcdf457

Please sign in to comment.