I have a problem with the iOS application (I am not an iOS developer, I am responsible for the API that this application uses) and DELETE.
Api uses 204 no-content responses for DELETE requests and which so far have worked fine for all client applications without problems.
The problem is that when using NSUrlConnection, all these DELETE requests are processed for more than 60 seconds or a failure due to a timeout.
This behavior is observed only in iOS implementations, other clients receive a response to the same request in less than 100 ms.
Is this normal behavior? Does anyone know of any fixes for hopefully not requiring an API recovery?
The code was created only to emulate this behavior and replicate the problem from the side of the API development team, but the problem is the same (the access token, of course, does not work, authentication works fine):
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *loadingLabel;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[_loadingLabel setHidden:true];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (IBAction)didButtonTouched:(id)sender {
NSString *url = @"https://api.noteables.com/editing-session/c180af93-ad3a-4751-a96a-dc47ff7732d4";
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
[request setHTTPMethod:@"DELETE"];
[request setValue:@"Bearer XXXX" forHTTPHeaderField:@"Authorization"];
[request setValue:@"Noteables/1.0 (iPhone; iOS 8.1.3; Scale/2.00)" forHTTPHeaderField:@"User-Agent"];
[request setValue:@"application/vnd.api.v1+json" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"en;q=1" forHTTPHeaderField:@"Accept-Language"];
NSDate *start = [NSDate date];
[_loadingLabel setHidden:false];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
double timePassed = [start timeIntervalSinceNow];
NSString *message = [NSString stringWithFormat:@"Elapsed: %f seconds", timePassed];
[_loadingLabel setHidden:true];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Result!" message: message delegate:self cancelButtonTitle:@"Am I satisfied with this?" otherButtonTitles:nil, nil];
[alert show];
NSLog(@"%@", response);
}];
}
@end
source
share