-
Notifications
You must be signed in to change notification settings - Fork 1
Requests
TypNull edited this page May 8, 2024
·
1 revision
$\text{\color{none}WebRequest<\color{orange}TOptions\color{none},\color{green}TCompleated\color{none}>}$ Class
This class serves as the base class for all WebRequest<TOptions, TCompleated> implementations that use the HttpClient.
-
$\text{\color{orange}TOptions}$ : Type:WebRequestOptions<TCompleated>- Specifies the type of options used by the web request.
-
$\text{\color{green}TCompleated}$ : Type: none- Specifies the return type of the request.
-
Url: Type:
string- This property gets the
stringthat represents the URL of theWebRequest<TOptions, TCompleated>.
- This property gets the
-
Constructor:
- This method initializes a new instance of the
WebRequest<TOptions, TCompleated>class. It takes astringURL that theWebRequest<TOptions, TCompleated>will call andTOptions?options used to modify theWebRequest<TOptions, TCompleated>.
- This method initializes a new instance of the
-
protectedGetPresetRequestMessage: Type:HttpRequestMessage- This method sets the headers of the
WebRequestOptions<TCompleated>to aHttpRequestMessage. It returns aHttpRequestMessagewith all the default headers set.
- This method sets the headers of the
This class represents a web request that only retrieves the headers of a URL. This is achieved by sending a HttpMethod.Head request.
-
Constructor:
- This method initializes a new instance of the
StatusRequestclass. It takes astringURL from which to retrieve the head response andWebRequestOptions<HttpResponseMessage>?options used to modify theRequest<TOptions, TCompleated, TFailed>.
- This method initializes a new instance of the
-
protected overrideRunRequestAsync: Type:Task<RequestReturn>- This method executes the
StatusRequestthat theHttpClientshould start. It returns aRequest<TOptions, TCompleated, TFailed>.RequestReturnobject indicating whether theStatusRequestwas successful and containing the return objects.
- This method executes the
-
privateSendHttpMenssage: Type:Task<HttpResponseMessage>- This method creates an
HttpRequestMessageand sends it. It returns theHttpResponseMessageresulting from the request.
- This method creates an
-
privateSetTimedToken: Type:void- This method sets up a cancellation token that will cancel the request after a specified timeout.
-
private staticSetRequestReturn: Type:void- This method populates the
Request<TOptions, TCompleated, TFailed>.RequestReturnobject with data from theHttpResponseMessage.
- This method populates the
A request that scans a website for references and files.
-
HTML: Type:
string- Gets the HTML content of the website.
-
BaseURl: Type:
string- Gets the base URL of the website.
-
Links: Type:
IReadOnlyList<WebItem>- Gets all the links on the website.
-
Videos: Type:
IReadOnlyList<WebItem>- Gets all the videos on the website.
-
Audios: Type:
IReadOnlyList<WebItem>- Gets all the audios on the website.
-
Images: Type:
IReadOnlyList<WebItem>- Gets all the images on the website.
-
Files: Type:
IReadOnlyList<WebItem>- Gets all the files on the website.
-
Scripts: Type:
IReadOnlyList<WebItem>- Gets all the scripts on the website.
-
UnknownType: Type:
IReadOnlyList<WebItem>- Gets all the unknown type files on the website.
-
CSS: Type:
IReadOnlyList<WebItem>- Gets all the CSS files on the website.
-
References: Type:
IReadOnlyList<WebItem>- Gets all the references on the website.
-
Constructor:
- Initializes a new instance of the SiteRequest class. Throws a UriFormatException when the provided URL is not well-formed.
-
privateSendHttpMenssage: Type:Task<HttpResponseMessage>- Sends an HTTP message.
-
protectedRunRequestAsync: Type:Task<RequestReturn>- Runs the request asynchronously.
-
privateScanReferences: Type:void- Scans the HTML for references.
-
privateSortReferneces: Type:void- Sorts the references by type.
-
privateScanOther: Type:IEnumerable<WebItem>- Scans for other items in the HTML.
-
privateScanReferences: Type:IEnumerable<WebItem>- Scans the tags for references.
-
privateFileExtensionToMediaTag: Type:string- Converts the file extension of a URI to a media tag.
-
privateGetTag: Type:string- Extracts the value of a specified tag from a string.
This class represents a GET request to download content from a specified URL. It inherits from the WebRequest<GetRequestOptions, string> class and implements the IProgressableRequest interface. It starts an HttpGet and saves the content stream to a file.
-
BytesWritten: Type:
long- This property gets the number of bytes that were written to the destination file.
-
ContentLength: Type:
long- This property gets the length of the content that will be downloaded. It returns the partial content length if the GetRequest is partial, otherwise it returns the full content length.
-
FullContentLength: Type:
Nullable<long>- This property gets the full length of the content, even if the GetRequest is partial.
-
PartialContentLength: Type:
Nullable<long>- This property gets the partial length of the content if the GetRequest is partial.
-
Filename: Type:
string- This property gets the name of the file that should be downloaded.
-
ContentName: Type:
string- This property gets the name of the content from the server.
-
ContentExtension: Type:
string- This property gets the extension of the content from the server.
-
ContentHeaders: Type:
Nullable<HttpContentHeaders>- This property gets the content headers of the last attempt.
-
FilePath: Type:
string- This property gets the path to the download file.
-
Progress: Type:
Progress<float>- This property gets the progress to receive updates of the download process.
-
privateRange: Type:LoadRange- This property gets the range that should be downloaded.
-
Constructor:
- This method initializes a new instance of the GetRequest class. It throws a NotSupportedException when LoadMode.Append and Range.Start are set.
-
IsPartial: Type:
bool- This method determines whether the request is partial. It returns true if the HTTP GET request is partial; otherwise, it returns false.
-
ShouldBePartial: Type:
bool- This method determines whether the last request should be partial. It returns true if the HTTP GET request has to be partial; otherwise, it returns false.
-
RunToCompleatedAsync: Type:
Task- This method allows the request to complete successfully without performing any additional actions.
-
SetContentLength: Type:
void- This method sets the content length of the request if known. It throws an ArgumentOutOfRangeException when the length is 0 or less.
-
Dispose: Type:
void- This method disposes the GetRequest instance. It is called automatically by the RequestHandler. It throws an AggregateException when one or more errors occur during the disposal of the GetRequest instance. It also throws an ArgumentException when an argument provided to a method is not valid, an ObjectDisposedException when an attempt is made to access an object that has been disposed, and an InvalidOperationException when a method call is invalid for the object's current state.
-
protectedRunRequestAsync: Type:Task<RequestReturn>- This method handles the request of this IRequest.
-
privateLoadWrittenBytes: Type:void- This method loads file info if the file exists. It throws an InvalidOperationException when the mode is not WriteMode.Append, BytesWritten is greater than 0, Filename is empty, or Filename does not contain '.'.
-
privateSetHttpGet: Type:void- This method initializes a new instance of the HttpGet class that holds the HTTP information.
-
privateLoadAsync: Type:Task<RequestReturn>- This method asynchronously loads the request.
-
privateReloadActions: Type:Task<HttpResponseMessage>- This method checks if further actions on the file or the request are necessary.
-
privateSetFileInfo: Type:void- This method sets the information for the HTTP request.
-
privateSendRequestAsync: Type:Task<HttpResponseMessage>- This method starts the HTTP GET request and overwrites the bytes written.
-
privateWriteToFileAsync: Type:Task- This method writes the response to a file.
-
privateWriterAsync: Type:Task- This method writes the response stream to the file stream.
-
privateIsFinished: Type:bool- This method determines whether the file download is finished. It returns true if the number of bytes written is equal to the content length; otherwise, it returns false.
-
privateCheckReload: Type:bool- This method checks if the HTTP request should be sent again when the filename exists on the drive. It returns true if a reload is necessary; otherwise, it returns false.
-
privateCheckClearFile: Type:bool- This method checks if the HTTP request should be partial but is not. It returns true if the file should be deleted; otherwise, it returns false.
This class represents a WebRequest that loads a response as a stream and saves it to a file.
-
Range: Type:
LoadRange- Gets the range of data that should be downloaded.
-
Filename: Type:
Nullable<string>- Gets the filename of the content that is being downloaded.
-
BytesWritten: Type:
long- Gets the number of bytes that have been written to the temporary file.
-
BytesDownloaded: Type:
long- Gets the number of bytes that have been downloaded.
-
ContentLength: Type:
long- Gets the length of the content that will be downloaded.
-
IsChunked: Type:
bool- Gets a value indicating whether this LoadRequest downloads in parts.
-
Destination: Type:
string- Gets the path to the download file.
-
TempDestination: Type:
string- Gets the path to the temporary file created during the download process.
-
Progress: Type:
Progress<float>- Gets the progress of the download process.
-
overrideException: Type:Nullable<AggregateException>- Gets the AggregateException that contains the exceptions thrown during the request.
-
overrideAttemptCounter: Type:int- Inherits from the base class.
-
overrideTask: Type:Task- Inherits from the base class.
-
LoadRequest: Type:
Constructor- Initializes a new instance of the LoadRequest class. Throws an IndexOutOfRangeException when the start of the range is greater than or equal to the end of the range. Throws a NotSupportedException when the start of the range is not null and the write mode is set to append.
-
overrideStart: Type:void- Starts the LoadRequest if it hasn't started or is paused.
-
overridePause: Type:void- Pauses the LoadRequest.
-
overrideCancel: Type:void- Cancels the LoadRequest.
-
overrideWait: Type:void- Blocks the current thread until the LoadRequest completes execution.
-
overrideDispose: Type:void- Releases all resources used by the LoadRequest.
-
asyncStartRequestAsync: Type:Task- Asynchronously starts the request.
-
protected override asyncRunRequestAsync: Type:Task<RequestReturn>- Executes the request asynchronously.
-
privateCreateDirectory: Type:void- Creates the directories specified in the options and sets them to the options.
-
privateCreateRequest: Type:void- Creates the GetRequest based on the options provided.
-
privateCreateChunk: Type:GetRequest- Creates a chunk of the GetRequest with the specified index and options.
-
privateOnStateChanged: Type:void- Handles the state change of the request.
-
privateOnFailure: Type:void- Handles the failure of the request.
-
privateOnInfosFetched: Type:void- Handles the fetching of information from the GetRequest.
-
private asyncCheckPartFile: Type:void- Checks the part file and loads its information if it exists. It also handles file creation based on the write mode.
-
privateExcludedExtensions: Type:void- Checks if the provided content extension is in the list of excluded extensions. If it is, an exception is added and the failure handler is invoked.
-
private asyncOnCompletion: Type:void- Handles the completion of the request. If the request is chunked, it starts merging the chunks. If the request is not chunked, it moves the temporary file to the destination.
-
privateTempToDestination: Type:void- Transfers the temporary file to the final destination.
-
privateClearOnFailure: Type:void- Resets the failure state of the request and deletes temporary files if necessary.