//
//  DOHTTPError.h
//  DOCore
//
//  Created by Ben Dolman on 9/25/14.
//
//

#import <Foundation/Foundation.h>

extern NSString * const DOHTTPErrorResponseStringKey;

/**
 * Error codes in this domain are the HTTP response codes (e.g. 500, 404, etc.)
 */
extern NSString *const DOHTTPErrorDomain;

/**
 * Returns an error in the DOHTTPErrorDomain
 */
extern NSError * DOHTTPErrorFromResponse(NSHTTPURLResponse *response, NSData *responseData);

/**
 * Validates that a response status code is acceptable.
 *
 * @param response The response to validate
 * @param acceptableCodes Index set of acceptable codes. If nil, then the set is 200-299.
 * @param outError If the response is not valid, this will be set to an error in the DOHTTPErrorDomain
 */
extern BOOL DOHTTPValidateResponse(NSHTTPURLResponse *response, NSIndexSet *acceptableCodes, NSError **outError);