Skip to content

Instantly share code, notes, and snippets.

@yuercl
Last active August 29, 2015 14:04
Show Gist options
  • Save yuercl/5b26375c6d5766007114 to your computer and use it in GitHub Desktop.
Save yuercl/5b26375c6d5766007114 to your computer and use it in GitHub Desktop.
//
// 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);
}
];
@yuercl
Copy link
Author

yuercl commented Aug 4, 2014

it is just a demo which is about how to decrypt http message body by using afnetworking framework . This is just base64 decode...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment