Last active
August 29, 2015 14:04
-
-
Save yuercl/5b26375c6d5766007114 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CLCryptResponseSerializer.h | |
// CMD_project | |
// | |
// Created by Chenlong on 14-8-4. | |
// Copyright (c) 2014年 Chenlong. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
#import "AFNetworking.h" | |
@interface CLCryptResponseSerializer : AFJSONResponseSerializer | |
@end | |
// | |
// CLCryptResponseSerializer.m | |
// CMD_project | |
// | |
// Created by Chenlong on 14-8-4. | |
// Copyright (c) 2014年 Chenlong. All rights reserved. | |
// | |
#import "CLCryptResponseSerializer.h" | |
@implementation CLCryptResponseSerializer | |
#pragma mark - AFURLResponseSerialization | |
- (id)responseObjectForResponse:(NSURLResponse *)response | |
data:(NSData *)data | |
error:(NSError *__autoreleasing *)error | |
{ | |
NSData *dataFromBase64 = [[NSData alloc] initWithBase64EncodedData:data options:NSDataBase64DecodingIgnoreUnknownCharacters]; | |
return [super responseObjectForResponse:response data:dataFromBase64 error:error]; | |
} | |
@end | |
usage: | |
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; | |
manager.responseSerializer = [RNCryptResponseSerializer serializer]; | |
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"]; | |
[manager GET:@"http://127.0.0.1/base64.php" | |
parameters:nil | |
success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
NSLog(@"JSON: %@", responseObject); | |
} | |
failure:^(AFHTTPRequestOperation *operation, NSError *error) { | |
NSLog(@"XXXXXXXError: %@", error); | |
} | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it is just a demo which is about how to decrypt http message body by using afnetworking framework . This is just base64 decode...