mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-01 17:39:46 +08:00
* Removed RestKit from inheritance hierarchy * Mappings are implemented as concrete classes * Mapper is much more flexible & powerful * Much more robust error handling * Serialization is reimplemented as an object mapping operation * Added ability to serialize to JSON natively * Reworked Core Data integration * Simplified the codebase substantially
53 lines
1.1 KiB
Objective-C
53 lines
1.1 KiB
Objective-C
//
|
|
// RKRequestSerialization.m
|
|
// RestKit
|
|
//
|
|
// Created by Blake Watters on 5/18/11.
|
|
// Copyright 2011 Two Toasters. All rights reserved.
|
|
//
|
|
|
|
#import "RKRequestSerialization.h"
|
|
|
|
@implementation RKRequestSerialization
|
|
|
|
@synthesize data = _data;
|
|
@synthesize MIMEType = _MIMEType;
|
|
|
|
- (id)initWithData:(NSData*)data MIMEType:(NSString*)MIMEType {
|
|
NSAssert(data, @"Cannot create a request serialization without Data");
|
|
NSAssert(MIMEType, @"Cannot create a request serialization without a MIME Type");
|
|
|
|
self = [super init];
|
|
if (self) {
|
|
_data = [data retain];
|
|
_MIMEType = [MIMEType retain];
|
|
}
|
|
|
|
return self;
|
|
}
|
|
|
|
+ (id)serializationWithData:(NSData*)data MIMEType:(NSString*)MIMEType {
|
|
return [[[RKRequestSerialization alloc] initWithData:data MIMEType:MIMEType] autorelease];
|
|
}
|
|
|
|
- (void)dealloc {
|
|
[_data release];
|
|
[_MIMEType release];
|
|
|
|
[super dealloc];
|
|
}
|
|
|
|
- (NSString*)HTTPHeaderValueForContentType {
|
|
return self.MIMEType;
|
|
}
|
|
|
|
- (NSData*)HTTPBody {
|
|
return self.data;
|
|
}
|
|
|
|
- (NSUInteger)HTTPHeaderValueForContentLength {
|
|
return [self.data length];
|
|
}
|
|
|
|
@end
|