<commit_before>//
//  TNTHttpConnection.h
//  NitroConnection
//
//  Created by <NAME> on 31/03/11.
//  Copyright 2011 <NAME>. All rights reserved.
//

#import <Foundation/Foundation.h>

// NitroConnection
#import "TNTHttpMethods.h"

/***********************************************************************
 *
 * Constants
 *
 ***********************************************************************/

FOUNDATION_EXPORT NSString * const TNTHttpConnectionErrorDomain;

FOUNDATION_EXPORT NSString * const TNTHttpConnectionErrorUserInfoResponseKey;
FOUNDATION_EXPORT NSString * const TNTHttpConnectionErrorUserInfoDataKey;

FOUNDATION_EXPORT const NSInteger TNTHttpConnectionErrorCodeHttpError;

/***********************************************************************
 *
 * Helper Types
 *
 ***********************************************************************/

typedef void ( ^TNTHttpConnectionDidStartBlock )();
typedef void ( ^TNTHttpConnectionSuccessBlock )( NSHTTPURLResponse *response, NSData *data );
typedef void ( ^TNTHttpConnectionErrorBlock )( NSError *error );

/***********************************************************************
 *
 * TNTHttpConnectionDelegate
 *
 ***********************************************************************/

@class TNTHttpConnection;

@protocol TNTHttpConnectionDelegate< NSObject >

	@optional
		-( void )onTNTHttpConnectionDidStart:( TNTHttpConnection * )connection;

        -( void )onTNTHttpConnection:( TNTHttpConnection * )connection didReceiveResponse:( NSHTTPURLResponse * )response withData:( NSData * )data;

		-( void )onTNTHttpConnection:( TNTHttpConnection * )connection didFailWithError:( NSError * )error;
@end

/***********************************************************************
 *
 * TNTHttpConnection
 *
 ***********************************************************************/

@interface TNTHttpConnection : NSObject

@property( nonatomic, readwrite, weak )id< TNTHttpConnectionDelegate > delegate;

@property( nonatomic, readonly, assign )BOOL requestAlive;

@property( nonatomic, readonly )NSURLRequest *lastRequest;
@property( nonatomic, readonly )NSHTTPURLResponse *lastResponse;

@property( nonatomic, readwrite, assign )NSTimeInterval timeoutInterval;
@property( nonatomic, readwrite, assign )NSURLRequestCachePolicy cachePolicy;

/**
 *  @name Request management
 */
-( void )startRequest:( NSURLRequest * )request;

-( void )startRequest:( NSURLRequest * )request
           onDidStart:( TNTHttpConnectionDidStartBlock )didStartBlock
            onSuccess:( TNTHttpConnectionSuccessBlock )successBlock
              onError:( TNTHttpConnectionErrorBlock )errorBlock;

-( void )startRequestWithMethod:( TNTHttpMethod )httpMethod
                            url:( NSString * )url
                         params:( NSDictionary * )params
                        headers:( NSDictionary * )headers;

-( void )startRequestWithMethod:( TNTHttpMethod )httpMethod
                            url:( NSString * )url
                         params:( NSDictionary * )params
                        headers:( NSDictionary * )headers
                     onDidStart:( TNTHttpConnectionDidStartBlock )didStartBlock
                      onSuccess:( TNTHttpConnectionSuccessBlock )successBlock
                        onError:( TNTHttpConnectionErrorBlock )errorBlock;

-( void )retry;

-( void )cancel;

/**
 *  @name Default configurations<commit_msg>Exporting new signature<commit_after>//
//  TNTHttpConnection.h
//  NitroConnection
//
//  Created by <NAME> on 31/03/11.
//  Copyright 2011 <NAME>. All rights reserved.
//

#import <Foundation/Foundation.h>

// NitroConnection
#import "TNTHttpMethods.h"

/***********************************************************************
 *
 * Constants
 *
 ***********************************************************************/

FOUNDATION_EXPORT NSString * const TNTHttpConnectionErrorDomain;

FOUNDATION_EXPORT NSString * const TNTHttpConnectionErrorUserInfoResponseKey;
FOUNDATION_EXPORT NSString * const TNTHttpConnectionErrorUserInfoDataKey;

FOUNDATION_EXPORT const NSInteger TNTHttpConnectionErrorCodeHttpError;

/***********************************************************************
 *
 * Helper Types
 *
 ***********************************************************************/

typedef void ( ^TNTHttpConnectionDidStartBlock )();
typedef void ( ^TNTHttpConnectionSuccessBlock )( NSHTTPURLResponse *response, NSData *data );
typedef void ( ^TNTHttpConnectionErrorBlock )( NSError *error );

/***********************************************************************
 *
 * TNTHttpConnectionDelegate
 *
 ***********************************************************************/

@class TNTHttpConnection;

@protocol TNTHttpConnectionDelegate< NSObject >

	@optional
		-( void )onTNTHttpConnectionDidStart:( TNTHttpConnection * )connection;

        -( void )onTNTHttpConnection:( TNTHttpConnection * )connection didReceiveResponse:( NSHTTPURLResponse * )response withData:( NSData * )data;

		-( void )onTNTHttpConnection:( TNTHttpConnection * )connection didFailWithError:( NSError * )error;
@end

/***********************************************************************
 *
 * TNTHttpConnection
 *
 ***********************************************************************/

@interface TNTHttpConnection : NSObject

@property( nonatomic, readwrite, weak )id< TNTHttpConnectionDelegate > delegate;

@property( nonatomic, readonly, assign )BOOL requestAlive;

@property( nonatomic, readonly )NSURLRequest *lastRequest;
@property( nonatomic, readonly )NSHTTPURLResponse *lastResponse;

@property( nonatomic, readwrite, assign )NSTimeInterval timeoutInterval;
@property( nonatomic, readwrite, assign )NSURLRequestCachePolicy cachePolicy;

/**
 *  @name Request management
 */
-( void )startRequest:( NSURLRequest * )request;

-( void )startRequest:( NSURLRequest * )request
           onDidStart:( TNTHttpConnectionDidStartBlock )didStartBlock
            onSuccess:( TNTHttpConnectionSuccessBlock )successBlock
              onError:( TNTHttpConnectionErrorBlock )errorBlock;

-( void )startRequestWithMethod:( TNTHttpMethod )httpMethod
                            url:( NSString * )url
                         params:( NSDictionary * )params
                        headers:( NSDictionary * )headers;

-( void )startRequestWithMethod:( TNTHttpMethod )httpMethod
                            url:( NSString * )url
                    queryString:( NSDictionary * )queryString
                           body:( NSData * )body
                        headers:( NSDictionary * )headers
                     onDidStart:( TNTHttpConnectionDidStartBlock )didStartBlock
                      onSuccess:( TNTHttpConnectionSuccessBlock )successBlock
                        onError:( TNTHttpConnectionErrorBlock )errorBlock;

-( void )startRequestWithMethod:( TNTHttpMethod )httpMethod
                            url:( NSString * )url
                         params:( NSDictionary * )params
                        headers:( NSDictionary * )headers
                     onDidStart:( TNTHttpConnectionDidStartBlock )didStartBlock
                      onSuccess:( TNTHttpConnectionSuccessBlock )successBlock
                        onError:( TNTHttpConnectionErrorBlock )errorBlock;

-( void )retry;

-( void )cancel;

/**
 *  @name Default configurations
{'fraction_non_alphanumeric': 0.2297976368328127, 'fraction_numerical': 0.002716284123319299, 'mean_word_length': 4.117442668519805, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4224053', 'n_tokens_mistral': 1938, 'n_tokens_neox': 1695, 'n_words': 392}