mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-22 20:18:53 +08:00
Migrate HTTP utility functions into a proper home
This commit is contained in:
43
Code/ObjectMapping/RKHTTPUtilities.h
Normal file
43
Code/ObjectMapping/RKHTTPUtilities.h
Normal file
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// RKHTTPUtilities.h
|
||||
// RestKit
|
||||
//
|
||||
// Created by Blake Watters on 8/24/12.
|
||||
// Copyright (c) 2012 RestKit. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
The HTTP status code classes
|
||||
|
||||
See http://tools.ietf.org/html/rfc2616#section-10
|
||||
*/
|
||||
enum {
|
||||
RKStatusCodeClassInformational = 100,
|
||||
RKStatusCodeClassSuccessful = 200,
|
||||
RKStatusCodeClassRedirection = 300,
|
||||
RKStatusCodeClassClientError = 400,
|
||||
RKStatusCodeClassServerError = 500
|
||||
};
|
||||
typedef NSUInteger RKStatusCodeClass;
|
||||
|
||||
/**
|
||||
Creates a new range covering the status codes in the given class.
|
||||
|
||||
@param statusCodeClass The status code class to create a range covering.
|
||||
@return A new range covering the status codes in the given class.
|
||||
*/
|
||||
NSRange RKStatusCodeRangeForClass(RKStatusCodeClass statusCodeClass);
|
||||
|
||||
/**
|
||||
Creates a new index set covering the status codes in the given class.
|
||||
|
||||
@param statusCodeClass The status code class to create an index set covering.
|
||||
@return A new index set covering the status codes in the given class.
|
||||
*/
|
||||
NSIndexSet * RKStatusCodeIndexSetForClass(RKStatusCodeClass statusCodeClass);
|
||||
|
||||
// TODO: Implement these guys...
|
||||
//NSString * RKStringFromStatusCode(NSInteger statusCode);
|
||||
//NSInteger RKStatusCodeFromString(NSString *statusCode);
|
||||
21
Code/ObjectMapping/RKHTTPUtilities.m
Normal file
21
Code/ObjectMapping/RKHTTPUtilities.m
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// RKHTTPUtilities.m
|
||||
// RestKit
|
||||
//
|
||||
// Created by Blake Watters on 8/24/12.
|
||||
// Copyright (c) 2012 RestKit. All rights reserved.
|
||||
//
|
||||
|
||||
#import "RKHTTPUtilities.h"
|
||||
|
||||
NSUInteger RKStatusCodeRangeLength = 100;
|
||||
|
||||
NSRange RKStatusCodeRangeForClass(RKStatusCodeClass statusCodeClass)
|
||||
{
|
||||
return NSMakeRange(statusCodeClass, RKStatusCodeRangeLength);
|
||||
}
|
||||
|
||||
NSIndexSet * RKStatusCodeIndexSetForClass(RKStatusCodeClass statusCodeClass)
|
||||
{
|
||||
return [NSIndexSet indexSetWithIndexesInRange:RKStatusCodeRangeForClass(statusCodeClass)];
|
||||
}
|
||||
@@ -18,41 +18,6 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#import <RestKit/RestKit.h>
|
||||
|
||||
/**
|
||||
The HTTP status code classes
|
||||
|
||||
See http://tools.ietf.org/html/rfc2616#section-10
|
||||
*/
|
||||
enum {
|
||||
RKStatusCodeClassInformational = 100,
|
||||
RKStatusCodeClassSuccessful = 200,
|
||||
RKStatusCodeClassRedirection = 300,
|
||||
RKStatusCodeClassClientError = 400,
|
||||
RKStatusCodeClassServerError = 500
|
||||
};
|
||||
typedef NSUInteger RKStatusCodeClass;
|
||||
|
||||
/**
|
||||
Creates a new range covering the status codes in the given class.
|
||||
|
||||
@param statusCodeClass The status code class to create a range covering.
|
||||
@return A new range covering the status codes in the given class.
|
||||
*/
|
||||
NSRange RKStatusCodeRangeForClass(RKStatusCodeClass statusCodeClass);
|
||||
|
||||
/**
|
||||
Creates a new index set covering the status codes in the given class.
|
||||
|
||||
@param statusCodeClass The status code class to create an index set covering.
|
||||
@return A new index set covering the status codes in the given class.
|
||||
*/
|
||||
NSIndexSet * RKStatusCodeIndexSetForClass(RKStatusCodeClass statusCodeClass);
|
||||
|
||||
// TODO: Implement these guys...
|
||||
//NSString * RKStringFromStatusCode(NSInteger statusCode);
|
||||
//NSInteger RKStatusCodeFromString(NSString *statusCode);
|
||||
|
||||
/**
|
||||
An RKResponseDescriptor object describes an object mapping configuration
|
||||
|
||||
@@ -21,18 +21,6 @@
|
||||
#import <RestKit/RKPathMatcher.h>
|
||||
#import "RKResponseDescriptor.h"
|
||||
|
||||
NSUInteger RKStatusCodeRangeLength = 100;
|
||||
|
||||
NSRange RKStatusCodeRangeForClass(RKStatusCodeClass statusCodeClass)
|
||||
{
|
||||
return NSMakeRange(statusCodeClass, RKStatusCodeRangeLength);
|
||||
}
|
||||
|
||||
NSIndexSet * RKStatusCodeIndexSetForClass(RKStatusCodeClass statusCodeClass)
|
||||
{
|
||||
return [NSIndexSet indexSetWithIndexesInRange:RKStatusCodeRangeForClass(statusCodeClass)];
|
||||
}
|
||||
|
||||
// Cloned from AFStringFromIndexSet -- method should be non-static for reuse
|
||||
static NSString * RKStringFromIndexSet(NSIndexSet *indexSet) {
|
||||
NSMutableString *string = [NSMutableString string];
|
||||
|
||||
Reference in New Issue
Block a user