diff options
| author | PliablePixels <pliablepixels@gmail.com> | 2015-06-25 16:10:07 -0400 |
|---|---|---|
| committer | PliablePixels <pliablepixels@gmail.com> | 2015-06-25 16:10:07 -0400 |
| commit | 65e7255c868bed3bb950e7e36ab786934edc559f (patch) | |
| tree | 085a58a4bc4a55111803dde9ab412dec9e9a8bb1 /plugins/com.synconset.cordovaHTTP/src/ios/TextResponseSerializer.m | |
| parent | 855a0e8ddc273b58066530a1b55a946021dfc56e (diff) | |
https now works with self-signed certificates (needs provisioning though)
Diffstat (limited to 'plugins/com.synconset.cordovaHTTP/src/ios/TextResponseSerializer.m')
| -rw-r--r-- | plugins/com.synconset.cordovaHTTP/src/ios/TextResponseSerializer.m | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/plugins/com.synconset.cordovaHTTP/src/ios/TextResponseSerializer.m b/plugins/com.synconset.cordovaHTTP/src/ios/TextResponseSerializer.m deleted file mode 100644 index 39d4080b..00000000 --- a/plugins/com.synconset.cordovaHTTP/src/ios/TextResponseSerializer.m +++ /dev/null @@ -1,58 +0,0 @@ -#import "TextResponseSerializer.h" - -static BOOL AFErrorOrUnderlyingErrorHasCode(NSError *error, NSInteger code) { - if (error.code == code) { - return YES; - } else if (error.userInfo[NSUnderlyingErrorKey]) { - return AFErrorOrUnderlyingErrorHasCode(error.userInfo[NSUnderlyingErrorKey], code); - } - - return NO; -} - -@implementation TextResponseSerializer - -+ (instancetype)serializer { - TextResponseSerializer *serializer = [[self alloc] init]; - return serializer; -} - -- (instancetype)init { - self = [super init]; - if (!self) { - return nil; - } - - self.acceptableContentTypes = [NSSet setWithObjects:@"text/plain", @"text/html", @"text/json", @"application/json", @"text/xml", @"application/xml", @"text/css", nil]; - - return self; -} - -#pragma mark - AFURLResponseSerialization - -- (id)responseObjectForResponse:(NSURLResponse *)response - data:(NSData *)data - error:(NSError *__autoreleasing *)error -{ - if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { - if (AFErrorOrUnderlyingErrorHasCode(*error, NSURLErrorCannotDecodeContentData)) { - return nil; - } - } - - // Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization. - // See https://github.com/rails/rails/issues/1742 - NSStringEncoding stringEncoding = self.stringEncoding; - if (response.textEncodingName) { - CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); - if (encoding != kCFStringEncodingInvalidId) { - stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); - } - } - - NSString *responseString = [[NSString alloc] initWithData:data encoding:stringEncoding]; - - return responseString; -} - -@end
\ No newline at end of file |
