2024-08-16 12:08:41 +00:00
|
|
|
/**
|
2024-10-28 11:21:47 +00:00
|
|
|
* NSURLSessionTaskPrivate.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017-2024 Free Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* Written by: Hugo Melder <hugo@algoriddim.com>
|
|
|
|
* Date: May 2024
|
|
|
|
* Author: Hugo Melder <hugo@algoriddim.com>
|
|
|
|
*
|
|
|
|
* This file is part of GNUStep-base
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* If you are interested in a warranty or support for this source code,
|
|
|
|
* contact Scott Christley <scottc@net-community.com> for more information.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free
|
2024-11-07 13:37:59 +00:00
|
|
|
* Software Foundation, Inc., 31 Milk Street #960789 Boston, MA 02196 USA.
|
2024-10-28 11:21:47 +00:00
|
|
|
*/
|
2024-08-16 12:08:41 +00:00
|
|
|
|
|
|
|
#import "Foundation/NSDictionary.h"
|
|
|
|
#import "Foundation/NSFileHandle.h"
|
|
|
|
#import "Foundation/NSURLSession.h"
|
|
|
|
#import <curl/curl.h>
|
|
|
|
|
|
|
|
@interface
|
2024-10-28 11:21:47 +00:00
|
|
|
NSURLSessionTask(Private)
|
2024-08-16 12:08:41 +00:00
|
|
|
|
2024-10-28 11:21:47 +00:00
|
|
|
- (instancetype)initWithSession: (NSURLSession *)session
|
|
|
|
request: (NSURLRequest *)request
|
|
|
|
taskIdentifier: (NSUInteger)identifier;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
2024-10-28 11:21:47 +00:00
|
|
|
-(CURL *)_easyHandle;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
|
|
|
/* Enable or disable libcurl verbose output. Disabled by default. */
|
2024-10-28 11:21:47 +00:00
|
|
|
-(void)_setVerbose: (BOOL)flag;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
|
|
|
/* This method is called by -[NSURLSession _checkForCompletion]
|
|
|
|
*
|
|
|
|
* We release the session (previously retained in -[NSURLSessionTask resume])
|
|
|
|
* here and inform the delegate about the transfer state.
|
|
|
|
*/
|
2024-10-28 11:21:47 +00:00
|
|
|
-(void)_transferFinishedWithCode: (CURLcode)code;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
|
|
|
/* Explicitly enable data upload with an optional estimated size. Set to 0 if
|
|
|
|
* not available.
|
|
|
|
*
|
|
|
|
* This may be used when a body stream is passed at a later stage
|
|
|
|
* (see URLSession:task:needNewBodyStream:).
|
|
|
|
*/
|
2024-10-28 11:21:47 +00:00
|
|
|
-(void)_enableUploadWithSize: (NSInteger)size;
|
|
|
|
-(void)_setBodyStream: (NSInputStream *)stream;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
2024-10-28 11:21:47 +00:00
|
|
|
-(void)_enableUploadWithData: (NSData *)data;
|
|
|
|
-(void)_enableAutomaticRedirects: (BOOL)flag;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
|
|
|
/* Assign with copying */
|
2024-10-28 11:21:47 +00:00
|
|
|
-(void)_setOriginalRequest: (NSURLRequest *)request;
|
|
|
|
-(void)_setCurrentRequest: (NSURLRequest *)request;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
2024-10-28 11:21:47 +00:00
|
|
|
-(void)_setResponse: (NSURLResponse *)response;
|
|
|
|
-(void)_setCookiesFromHeaders: (NSDictionary *)headers;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
2024-10-28 11:21:47 +00:00
|
|
|
-(void)_setCountOfBytesSent: (int64_t)count;
|
|
|
|
-(void)_setCountOfBytesReceived: (int64_t)count;
|
|
|
|
-(void)_setCountOfBytesExpectedToSend: (int64_t)count;
|
|
|
|
-(void)_setCountOfBytesExpectedToReceive: (int64_t)count;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
2024-10-28 11:21:47 +00:00
|
|
|
-(NSMutableDictionary *)_taskData;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
2024-10-28 11:21:47 +00:00
|
|
|
-(NSURLSession *)_session;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
|
|
|
/* Task specific properties.
|
|
|
|
*
|
|
|
|
* See GSURLSessionProperties in NSURLSessionPrivate.h.
|
|
|
|
*/
|
2024-10-28 11:21:47 +00:00
|
|
|
-(NSInteger)_properties;
|
|
|
|
-(void)_setProperties: (NSInteger)properties;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
|
|
|
/* This value is periodically checked in progress_callback.
|
|
|
|
* We then abort the transfer in the progress_callback if this flag is set.
|
|
|
|
*/
|
2024-10-28 11:21:47 +00:00
|
|
|
-(BOOL)_shouldStopTransfer;
|
|
|
|
-(void)_setShouldStopTransfer: (BOOL)flag;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
2024-10-28 11:21:47 +00:00
|
|
|
-(NSInteger)_numberOfRedirects;
|
|
|
|
-(void)_setNumberOfRedirects: (NSInteger)redirects;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
2024-10-28 11:21:47 +00:00
|
|
|
-(NSInteger)_headerCallbackCount;
|
|
|
|
-(void)_setHeaderCallbackCount: (NSInteger)count;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
2024-10-28 11:21:47 +00:00
|
|
|
-(NSFileHandle *)_createTemporaryFileHandleWithError: (NSError **)error;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface
|
2024-10-28 11:21:47 +00:00
|
|
|
NSURLSessionDataTask(Private)
|
2024-08-16 12:08:41 +00:00
|
|
|
|
|
|
|
- (GSNSURLSessionDataCompletionHandler)_completionHandler;
|
2024-10-28 11:21:47 +00:00
|
|
|
-(void)_setCompletionHandler: (GSNSURLSessionDataCompletionHandler)handler;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface
|
2024-10-28 11:21:47 +00:00
|
|
|
NSURLSessionDownloadTask(Private)
|
2024-08-16 12:08:41 +00:00
|
|
|
|
|
|
|
- (GSNSURLSessionDownloadCompletionHandler)_completionHandler;
|
|
|
|
|
2024-10-28 11:21:47 +00:00
|
|
|
-(int64_t)_countOfBytesWritten;
|
|
|
|
-(void)_updateCountOfBytesWritten: (int64_t)count;
|
|
|
|
-(void)_setCompletionHandler: (GSNSURLSessionDownloadCompletionHandler)handler;
|
2024-08-16 12:08:41 +00:00
|
|
|
|
|
|
|
@end
|