//
//  XSHttpHelper.h
//  nochange
//
//  Created by mac on 2024/10/23.
//

#ifndef XSHttpHelper_h
#define XSHttpHelper_h


typedef void (^request_callback)(NSData *);
typedef void (^error_callback)(NSError *);
typedef void (^download_callback)(NSString*);
typedef void (^rt_str_callback)(NSString*);

@interface XSHttpHelper : NSObject
// @property (nonatomic, strong) NSURLSession *session;
@property (nonatomic, strong) NSURLSessionDataTask *dataTask;
@property (nonatomic, strong) NSURLSessionDataTask *postDataTask;
@property (nonatomic, assign) NSTimeInterval timeoutInterval; // 新增超时属性

- (void) doGET: (NSString*) urlStr withCallback:(request_callback) callback withError: (error_callback) errorCallback;
- (NSData *) doGET: (NSString*) urlStr;
- (void) doPOST: (NSString*) urlStr json: (NSString *)json withCallback:(request_callback) callback  withError: (error_callback) errorCallback;
- (NSData*) doPOST:(NSString *)urlStr json:(NSString *)json;
- (void)cancelAllRequests; // 新增取消所有请求方法
- (void)cancelCurrentGETRequest; // 新增取消当前GET请求方法
- (void)cancelCurrentPOSTRequest; // 新增取消当前POST请求方法
- (void)requestNetworkPermissions;
@end

#endif /* XSHttpHelper_h */
