import type { _NSURLDownload } from "../WebKit/NSURLDownload.js";
import type { _NSError } from "./NSError.js";
import type { _NSString } from "./NSString.js";
import type { _NSURLAuthenticationChallenge } from "./NSURLAuthenticationChallenge.js";
import type { _NSURLProtectionSpace } from "./NSURLProtectionSpace.js";
import type { _NSURLRequest } from "./NSURLRequest.js";
import type { _NSURLResponse } from "./NSURLResponse.js";
export interface _NSURLDownloadDelegate {
    /**
     * @method downloadDidBegin: @abstract This method is called immediately after the download has started. @param download The download that just started downloading.
     */
    downloadDidBegin$?(download: _NSURLDownload): void;
    /**
     * @method download:willSendRequest:redirectResponse: @abstract This method is called if the download must load another request because the previous request was redirected. @param download The download that will send the request. @param request The request that will be used to continue loading. @result The request to be used; either the request parameter or a replacement. If nil is returned, the download is cancelled. @discussion This method gives the delegate an opportunity to inspect the request that will be used to continue loading the request, and modify it if necessary.
     */
    download$willSendRequest$redirectResponse$?(download: _NSURLDownload, request: _NSURLRequest, redirectResponse: _NSURLResponse | null): _NSURLRequest | null;
    /**
     * @method download:canAuthenticateAgainstProtectionSpace: @abstract This method gives the delegate an opportunity to inspect an NSURLProtectionSpace before an authentication attempt is made. @discussion If implemented, will be called before connection:didReceiveAuthenticationChallenge to give the delegate a chance to inspect the protection space that will be authenticated against. Delegates should determine if they are prepared to respond to the authentication method of the protection space and if so, return YES, or NO to allow default processing to handle the authentication. If this delegate is not implemented, then default processing will occur (typically, consulting the user's keychain and/or failing the connection attempt. @param connection an NSURLConnection that has an NSURLProtectionSpace ready for inspection @param protectionSpace an NSURLProtectionSpace that will be used to generate an authentication challenge @result a boolean value that indicates the willingness of the delegate to handle the authentication
     */
    download$canAuthenticateAgainstProtectionSpace$?(connection: _NSURLDownload, protectionSpace: _NSURLProtectionSpace): boolean;
    /**
     * @method download:didReceiveAuthenticationChallenge: @abstract Start authentication for a given challenge @param download The download that needs authentication. @param challenge The NSURLAuthenticationChallenge for which to start authentication. @discussion Call useCredential:forAuthenticationChallenge:, continueWithoutCredentialForAuthenticationChallenge: or cancel on the connection sender when done.
     */
    download$didReceiveAuthenticationChallenge$?(download: _NSURLDownload, challenge: _NSURLAuthenticationChallenge): void;
    /**
     * @method download:didCancelAuthenticationChallenge: @abstract Cancel authentication for a given request @param download The download that's cancelling @param challenge The NSURLAuthenticationChallenge to cancel authentication for
     */
    download$didCancelAuthenticationChallenge$?(download: _NSURLDownload, challenge: _NSURLAuthenticationChallenge): void;
    /**
     * @method downloadShouldUseCredentialStorage @abstract This method allows the delegate to inform the url loader that it should not consult the credential storage for the download. @discussion This method will be called before any attempt to authenticate is attempted on a download. By returning NO the delegate is telling the download to not consult the credential storage and taking responsibility for providing any credentials for authentication challenges. Not implementing this method is the same as returning YES. The delegate is free to consult the credential storage itself when it receives a didReceiveAuthenticationChallenge message. @param download the NSURLDownload object asking if it should consult the credential storage. @result NO if the download should not consult the credential storage, Yes if it should.
     */
    downloadShouldUseCredentialStorage$?(download: _NSURLDownload): boolean;
    /**
     * @method download:didReceiveResponse: @abstract This method is called when the download has received a response from the server. @param download The download that now has a NSURLResponse available for inspection. @param response The NSURLResponse object for the given download. @discussion In some rare cases, multiple responses may be received for a single download. This occurs with multipart/x-mixed-replace, or "server push". In this case, the client should assume that each new response resets progress so far for the resource back to 0, and should check the new response for the expected content length.
     */
    download$didReceiveResponse$?(download: _NSURLDownload, response: _NSURLResponse): void;
    /**
     * @method download:willResumeWithResponse:fromByte: @abstract This method is called when the download has received a response from the server after attempting to resume a download. @param download The download that now has a NSURLResponse available for inspection. @param response The NSURLResponse object for the given download. @param startingByte The number of bytes from where the download will resume. 0 indicates that the download will restart from the beginning. @discussion download:willResumeWithResponse:fromByte: is called instead of download:didReceiveResponse: when a download is initialized with initWithResumeData:delegate:path:.
     */
    download$willResumeWithResponse$fromByte$?(download: _NSURLDownload, response: _NSURLResponse, startingByte: number): void;
    /**
     * @method download:didReceiveDataOfLength: @abstract This method is called when the download has loaded data. @param download The download that has received data. @param length The length of the received data. @discussion This method will be called one or more times.
     */
    download$didReceiveDataOfLength$?(download: _NSURLDownload, length: number): void;
    /**
     * @method download:shouldDecodeSourceDataOfMIMEType: @abstract This method is called if the download detects that the downloading file is encoded. @param download The download that has detected that the downloading file is encoded. @param encodingType A MIME type expressing the encoding type. @result Return YES to decode the file, NO to not decode the file. @discussion An encoded file is encoded in MacBinary, BinHex or gzip format. This method may be called more than once if the file is encoded multiple times. This method is not called if the download is not encoded.
     */
    download$shouldDecodeSourceDataOfMIMEType$?(download: _NSURLDownload, encodingType: _NSString): boolean;
    /**
     * @method download:decideDestinationWithSuggestedFilename: @abstract This method is called when enough information has been loaded to decide a destination for the downloaded file. @param download The download that requests the download path. @param filename The suggested filename for deciding the path of the downloaded file. The filename is either derived from the last path component of the URL and the MIME type or if the download was encoded, it is the filename specified in the encoding. @discussion Once the delegate has decided a path, it should call setDestination:allowOverwrite:. The delegate may respond immediately or later. This method is not called if setDestination:allowOverwrite: has already been called.
     */
    download$decideDestinationWithSuggestedFilename$?(download: _NSURLDownload, filename: _NSString): void;
    /**
     * @method download:didCreateDestination: @abstract This method is called after the download creates the downloaded file. @param download The download that created the downloaded file. @param path The path of the downloaded file.
     */
    download$didCreateDestination$?(download: _NSURLDownload, path: _NSString): void;
    /**
     * @method downloadDidFinish: @abstract This method is called when the download has finished downloading. @param download The download that has finished downloading. @discussion This method is called after all the data has been received and written to disk. This method or download:didFailWithError: will only be called once.
     */
    downloadDidFinish$?(download: _NSURLDownload): void;
    /**
     * @method download:didFailWithError: @abstract This method is called when the download has failed. @param download The download that ended in error. @param error The error caused the download to fail. @discussion This method is called when the download encounters a network or file I/O related error. This method or downloadDidFinish: will only be called once.
     */
    download$didFailWithError$?(download: _NSURLDownload, error: _NSError): void;
}
