GenHTTP.Modules.IO 10.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package GenHTTP.Modules.IO --version 10.2.0
                    
NuGet\Install-Package GenHTTP.Modules.IO -Version 10.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GenHTTP.Modules.IO" Version="10.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GenHTTP.Modules.IO" Version="10.2.0" />
                    
Directory.Packages.props
<PackageReference Include="GenHTTP.Modules.IO" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GenHTTP.Modules.IO --version 10.2.0
                    
#r "nuget: GenHTTP.Modules.IO, 10.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GenHTTP.Modules.IO@10.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GenHTTP.Modules.IO&version=10.2.0
                    
Install as a Cake Addin
#tool nuget:?package=GenHTTP.Modules.IO&version=10.2.0
                    
Install as a Cake Tool

GenHTTP.Modules.IO

Provides I/O related functionality to be used within a GenHTTP application.

Resources

Access to resources such as files are abstracted in GenHTTP via IResourceTree and IResource. The I/O module adds common implementations to load resources from strings, files or an assembly. It also adds useful features such as virtual resource trees or change tracking for resources.

See the documentation for more details.

Content Implementations

Besides the resource implementations, the module adds some IResponseContent implementations that can be used to directly set the content when building a response.

See the documentation for more details.

Providers

The following handlers and concerns are provided by this module.

Handlers / Concerns

Those entry points allow to quickly create concerns and handlers without the need of implementing interfaces and of providing builders.

For documentation, see the concern and handler pages.

Content

Provides a single resource to a requesting client. In contrast to downloads, the response is expected to be consumed by the client without actually downloading it to a local file. The Content-Type is computed from the given resource. For named resources, the logic will try to guess the content type from the file extension.

using GenHTTP.Engine.Internal;

using GenHTTP.Modules.IO;
using GenHTTP.Modules.Layouting;
using GenHTTP.Modules.Practices;

var content = Content.From(Resource.FromString("Hello World!"));

var app = Layout.Create()
                .Add("hello", content);

await Host.Create()
          .Handler(app)
          .Defaults()
          .Console()
          .RunAsync();

The module also provides extensions

Downloads

Allows clients to download a single resource and to specify the name as it should be presented to the user. The logic tries to automatically determine the Content-Type of the resource.

using GenHTTP.Api.Protocol;

using GenHTTP.Engine.Internal;

using GenHTTP.Modules.IO;
using GenHTTP.Modules.Layouting;
using GenHTTP.Modules.Practices;

var file = Resource.FromFile("./my.pdf");

var download = Download.From(file)
                       .FileName("invoice-user-1234.pdf") // optional, would be "my.pdf" otherwise
                       .Type(ContentType.ApplicationPdf); // optional, automatically detected here

var app = Layout.Create()
                .Add("get-invoice", download);

await Host.Create()
          .Handler(app)
          .Defaults()
          .Console()
          .RunAsync();

Range Support

This concern allows clients to request only a specific part of the data provided by the inner handler. For this to work, the inner handler needs to set a Content-Length on the response. Chunked responses are not supported. Requires the HTTP method to be GET or HEAD.

The concern will set a Accept-Ranges: bytes header to signal range support to the client.

The client can then request a specific byte range using the Range header, e.g. Range: 100- to skip the first 100 bytes of the response.

While this concern can safely be applied to the root handler, it is recommended to apply it only to the handlers where the functionality is needed, as there is some runtime overhead for each request.

using GenHTTP.Engine.Internal;

using GenHTTP.Modules.IO;
using GenHTTP.Modules.Layouting;
using GenHTTP.Modules.Practices;

var download = Download.From(Resource.FromFile("my-large.bin"))
                       .AddRangeSupport();

var app = Layout.Create()
                .Add("file", download);

await Host.Create()
          .Handler(app)
          .Defaults()
          .Console()
          .RunAsync();
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (36)

Showing the top 5 NuGet packages that depend on GenHTTP.Modules.IO:

Package Downloads
GenHTTP.Core

Basic dependencies for projects using the GenHTTP framework, including the engine itself

GenHTTP.Modules.Pages

Allows to generate and serve HTML pages

GenHTTP.Modules.Conversion

Allows to read and write responses in additional data formats such as JSON or XML

GenHTTP.Modules.Practices

Best practices to configure a GenHTTP webserver instance for production

GenHTTP.Modules.Webservices

Module to add REST-based webservices to a GenHTTP project.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.4.0 1,021 12/30/2025
10.3.0 1,671 12/19/2025
10.2.0 1,226 12/11/2025
10.1.2 1,041 12/10/2025
10.1.1 922 11/28/2025
10.1.0 1,290 11/20/2025
10.0.0 2,063 11/11/2025
9.8.0 2,478 7/9/2025
9.7.0 1,925 2/27/2025
9.6.2 2,416 1/31/2025
9.6.1 251 1/31/2025
9.6.0 1,029 1/22/2025
9.5.0 606 1/10/2025
9.4.0 723 12/20/2024
9.3.0 578 12/11/2024
9.2.0 728 11/29/2024
9.1.0 1,177 11/22/2024
9.0.0 880 11/13/2024
8.6.0 2,569 7/1/2024
8.5.0 1,727 6/4/2024
8.4.0 1,021 5/28/2024
8.3.0 1,859 4/23/2024
8.2.0 1,853 3/12/2024
8.1.1 1,098 2/26/2024
8.1.0 1,494 1/4/2024
8.0.0 1,996 11/23/2023
7.0.0 1,974 7/3/2023
6.4.0 10,220 8/23/2022
6.3.5 4,187 7/1/2022
6.3.4 3,422 4/26/2022
6.3.3 3,153 2/21/2022
6.3.2 3,070 1/24/2022
6.3.1 2,161 12/21/2021
6.3.0 2,118 12/20/2021
6.2.0 2,570 12/3/2021
6.1.0 7,687 11/24/2021
6.0.0 2,122 11/9/2021
5.2.3 708 7/9/2021
5.2.0 3,538 1/18/2021
5.1.0 2,933 12/13/2020
5.0.0 2,358 11/20/2020
4.1.0 2,831 10/22/2020
4.0.0 2,902 10/5/2020