|
|
|
@ -17,13 +17,14 @@
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.parameters = @{};
|
|
|
|
|
_parameters = @{};
|
|
|
|
|
self.shouldHaveAuthorizationHeaders = YES;
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (id)init {
|
|
|
|
|
- (instancetype)init
|
|
|
|
|
{
|
|
|
|
|
OWSRaiseException(NSInternalInconsistencyException, @"You must use the initWithURL: method");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
@ -31,21 +32,41 @@
|
|
|
|
|
#pragma clang diagnostic push
|
|
|
|
|
#pragma clang diagnostic ignored "-Wobjc-designated-initializers"
|
|
|
|
|
|
|
|
|
|
- (id)initWithURL:(NSURL *)URL
|
|
|
|
|
cachePolicy:(NSURLRequestCachePolicy)cachePolicy
|
|
|
|
|
timeoutInterval:(NSTimeInterval)timeoutInterval {
|
|
|
|
|
- (instancetype)initWithURL:(NSURL *)URL
|
|
|
|
|
cachePolicy:(NSURLRequestCachePolicy)cachePolicy
|
|
|
|
|
timeoutInterval:(NSTimeInterval)timeoutInterval
|
|
|
|
|
{
|
|
|
|
|
OWSRaiseException(NSInternalInconsistencyException, @"You must use the initWithURL method");
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithURL:(NSURL *)URL
|
|
|
|
|
method:(NSString *)method
|
|
|
|
|
parameters:(nullable NSDictionary<NSString *, id> *)parameters
|
|
|
|
|
{
|
|
|
|
|
OWSAssert(URL);
|
|
|
|
|
OWSAssert(method.length > 0);
|
|
|
|
|
OWSAssert(parameters);
|
|
|
|
|
|
|
|
|
|
self = [super initWithURL:URL
|
|
|
|
|
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
|
|
|
|
|
timeoutInterval:textSecureHTTPTimeOut];
|
|
|
|
|
if (!self) {
|
|
|
|
|
return nil;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_parameters = parameters ?: @{};
|
|
|
|
|
[self setHTTPMethod:method];
|
|
|
|
|
self.shouldHaveAuthorizationHeaders = YES;
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (instancetype)requestWithUrl:(NSURL *)url
|
|
|
|
|
method:(NSString *)method
|
|
|
|
|
parameters:(NSDictionary<NSString *, id> *)parameters
|
|
|
|
|
parameters:(nullable NSDictionary<NSString *, id> *)parameters
|
|
|
|
|
{
|
|
|
|
|
TSRequest *request = [[TSRequest alloc] initWithURL:url];
|
|
|
|
|
[request setHTTPMethod:method];
|
|
|
|
|
request.parameters = parameters;
|
|
|
|
|
return request;
|
|
|
|
|
return [[TSRequest alloc] initWithURL:url method:method parameters:parameters];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|