Skip to content

Base Classes

TypNull edited this page May 8, 2024 · 1 revision

Summary

HttpGet Partial Class

This class is designed to instantiate an HttpGet object that sends HTTP GET requests to a server and receives responses via the HttpClient. The primary instance of System.Net.Http.HttpClient is utilized here. This instance is responsible for managing HttpRequests for any IRequest that uses it.

Properties:

  • static HttpClient: Type: HttpClient
    • Primary instance of HttpClient.
  • Range: Type: LoadRange
    • Gets or sets the primary download range of the HTTP GET request.
  • SecondRange: Type: LoadRange
    • Sets a secondary range. The values between the primary and secondary ranges will be set as the new primary range.
  • Timeout: Type: Nullable<TimeSpan>
    • Gets or sets the timeout for the HTTP GET request.
  • Token: Type: CancellationToken
    • Gets the cancellation token for this HTTP GET request.
  • HeadRequestException: Type: Nullable<Exception>
    • Gets the exception if the HEAD request failed.
  • FullContentLength: Type: Nullable<long>
    • Gets the full content length of the response.
  • PartialContentLength: Type: Nullable<long>
    • Gets the length of the part of the content that will be received when the range is set.

Methods:

  • Constructor:
    • Initializes a new instance of the HttpGet class.
  • SetContentLength: Type: void
    • Sets the content length for the HTTP GET request.
  • Dispose: Type: void
    • Disposes this object and suppresses finalization.
  • AddBytesToStart: Type: void
    • Adds a specified value to the start of the range for the request. The start value does not change.
  • IsPartial: Type: bool
    • Checks if the last request was partial.
  • HasToBePartial: Type: bool
    • Determines if the next request should be partial.
  • private LoadContentLength: Type: long
    • Initializes the lazy _contentLength. This method is called only once.
  • private GetContentLength: Type: long
    • Retrieves the content length from the server.
  • public async LoadResponseAsync: Type: Task
    • Creates an instance of HttpResponseMessage.
  • private IsLengthSet: Type: bool
    • Checks if the content length is set.
  • private async Task SendHttpMenssage: Type: Task
    • Sends an HTTP request message.
  • private UpdateContentLength: Type: void
    • Updates the content length based on the response.
  • private TimedTokenOrDefault: Type: CancellationToken
    • Gets a cancellation token with a timeout if one is set; otherwise, gets the default cancellation token.
  • private InitAddToStart: Type: void
    • Initializes the start of the range.
  • private SetRange: Type: void
    • Sets the range and second range of Options to a fitting value for the request.
  • private static CloneRequestMessage: Type: HttpRequestMessage
    • Clones a HttpRequestMessage.

LoadRange Readonly Struct

Represents a range of data to be loaded. This could be an absolute range (in bytes), a relative range (in parts), or a promille range.

Properties:

  • Length: Type: Nullable<long>
    • Gets the length of the LoadRange.
  • Start: Type: Nullable<long>
    • Gets the start point of the LoadRange in bytes. This value is zero-based.
  • End: Type: Nullable<long>
    • Gets the end point of the LoadRange in bytes. This value is zero-based.
  • IsAbsolut: Type: bool
    • Indicates whether the values of the LoadRange are absolute.
  • IsPromille: Type: bool
    • Indicates whether the values of the LoadRange are promille values between 0 and 1000.

Methods:

  • LoadRange: Type: void
    • Initializes a new instance of the LoadRange struct with absolute start and end values.
  • LoadRange: Type: void
    • Initializes a new instance of the LoadRange struct with a relative range based on the part and total length.
  • LoadRange: Type: void
    • Initializes a new instance of the LoadRange struct with a promille range.
  • IsEmpty: Type: bool
    • Indicates whether the LoadRange object is empty.
  • static ToAbsolut: Type: LoadRange
    • Converts a relative LoadRange to an absolute range, based on the given total length.