← All compilation units

Flyology.HTTP.Client.Request_Bodies.Files

Description

Supplies positional file-range request bodies. A source borrows an open descriptor, never changes its file position, and never closes it.

Declared_Length

function Declared_Length
  (Item : Range_Source) return Body_Length

@exclude

Parameters
Item

File range to inspect

Return value

Exact configured range length

Range_Source

type Range_Source
  (File   : not null access Flyology.IO.Files.File_Descriptor;
   Offset : Flyology.IO.Files.File_Offset;
   Count  : Body_Size)
is limited new Rewindable_Request_Body_Source with private;

Borrow Count bytes beginning at Offset. File must remain open through Execute, and its bytes must remain unchanged until Execute returns so a stale-transport retry reproduces the same request. The range must fit File_Offset; invalid ranges are rejected when Execute queries Declared_Length. Reaching end-of-file early causes the client's known-length source validation to raise Request_Body_Error.

Read

procedure Read
  (Item     : in out Range_Source;
   Data     : out Ada.Streams.Stream_Element_Array;
   Last     : out Ada.Streams.Stream_Element_Offset;
   Finished : out Boolean;
   Timeout  : Duration;
   Token    : access Flyology.Cancellation.Token)

@exclude

Parameters
Item

File range to advance

Data

Client staging array

Last

Last produced byte

Finished

Whether the range or file is exhausted

Timeout

Remaining exchange timeout

Token

Exchange cancellation token

Rewind

procedure Rewind (Item : in out Range_Source)

Rewind a file range for an explicit later Execute call. Execute can also invoke this operation for its guarded stale-transport retry; the descriptor remains borrowed.

Parameters
Item

Source whose next read returns to Offset