Encamina.Enmarcha.Net.Http
8.1.7-preview-03
See the version list below for details.
dotnet add package Encamina.Enmarcha.Net.Http --version 8.1.7-preview-03
NuGet\Install-Package Encamina.Enmarcha.Net.Http -Version 8.1.7-preview-03
<PackageReference Include="Encamina.Enmarcha.Net.Http" Version="8.1.7-preview-03" />
paket add Encamina.Enmarcha.Net.Http --version 8.1.7-preview-03
#r "nuget: Encamina.Enmarcha.Net.Http, 8.1.7-preview-03"
// Install Encamina.Enmarcha.Net.Http as a Cake Addin #addin nuget:?package=Encamina.Enmarcha.Net.Http&version=8.1.7-preview-03&prerelease // Install Encamina.Enmarcha.Net.Http as a Cake Tool #tool nuget:?package=Encamina.Enmarcha.Net.Http&version=8.1.7-preview-03&prerelease
HTTP
This project provides utilities related to HTTP, covering aspects such as the most common media types and common constants, ultimately providing a collection of useful tools for HTTP.
Setup
Nuget package
First, install NuGet. Then, install Encamina.Enmarcha.Net.Http from the package manager console:
PM> Install-Package Encamina.Enmarcha.Net.Http
.NET CLI:
First, install .NET CLI. Then, install Encamina.Enmarcha.Net.Http from the .NET CLI:
dotnet add package Encamina.Enmarcha.Net.Http
How to use
Media types
MediaTypeNames provides common media type (formerly known as MIME type) names for file formats and format contents.
Console.WriteLine(Encamina.Enmarcha.Net.Http.MediaTypeNames.Image.Jpeg);
// image/jpeg
Console.WriteLine(Encamina.Enmarcha.Net.Http.MediaTypeNames.Application.Json);
// application/json
Console.WriteLine(Encamina.Enmarcha.Net.Http.MediaTypeNames.Text.Csv);
// text/csv
MediaTypeFileExtensionMapper a mapping between file extensions and media types (former MIME). The main difference with FileExtensionContentTypeProvider is that this considers various media types per extension, which is usefull for scenarios like for example zip files which can be identified as application/zip, application/zip-compressed, or application/x-zip-compressed.
var mediaTypeFileExtensionMapper = new MediaTypeFileExtensionMapper();
// Gets the media types mapped to the given extension
var zipMediaTypes = mediaTypeFileExtensionMapper.GetMediaTypesFromExtension(".zip");
// zipMediaTypes => application/zip, application/zip-compressed, application/x-zip-compressed
// Gets the current mappings between extensions and media types.
zipMediaTypes = mediaTypeFileExtensionMapper.Mappings[".zip"];
// zipMediaTypes => application/zip, application/zip-compressed, application/x-zip-compressed
// Gets the extensions mapped to the given media type.
var zipExtension = mediaTypeFileExtensionMapper.GetExtensionsFromMediaType("application/zip");
// zipExtension => .zip
Alternatively, you can create a new instance of MediaTypeFileExtensionMapper
with your own mappings or merge new mappings with the default ones.
var customMappings = new Dictionary<string, IEnumerable<string>>()
{
{ ".odt", new[] { @"application/vnd.oasis.opendocument.text" } },
};
// It only contains the mapping for .odt.
var customMediaTypeFileExtensionMapper = new MediaTypeFileExtensionMapper(customMappings);
// It contains all the default mappings plus the mapping for .odt.
var mergedMediaTypeFileExtensionMapper = new MediaTypeFileExtensionMapper(customMappings, mergeWithDefaultMappings: true);
Constants
A collection of properties that represent common constant values. It includes HTTP headers that can be used as custom HTTP headers, for example, as Constants.HttpHeaders.CorrelationId
or Constants.HttpHeaders.SourceUrl
.
HttpContextExtensions
Extension helper methods when working with an HttpContext
.
For example, in a Web API, you may want to retrieve the value of a request header:
// ...
HttpContext httpContext;
// ...
// Reads values from the request header. A default value to return if the header is not found.
var myCustomHeaderValue = myhttpContext.ReadValueFromRequestHeader("my-custom-header", defaultValue: "no-custom-header");
Product | Versions 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. |
-
net8.0
- CommunityToolkit.Diagnostics (>= 8.2.2)
- Encamina.Enmarcha.Core (>= 8.1.7-preview-03)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Encamina.Enmarcha.Net.Http:
Package | Downloads |
---|---|
Encamina.Enmarcha.AspNet.Mvc.Formatters
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.2.0 | 338 | 10/22/2024 |
8.2.0-preview-01-m01 | 107 | 9/17/2024 |
8.1.9-preview-03 | 65 | 11/19/2024 |
8.1.9-preview-02 | 64 | 10/22/2024 |
8.1.9-preview-01 | 129 | 10/4/2024 |
8.1.8 | 151 | 9/23/2024 |
8.1.8-preview-07 | 179 | 9/12/2024 |
8.1.8-preview-06 | 154 | 9/11/2024 |
8.1.8-preview-05 | 97 | 9/10/2024 |
8.1.8-preview-04 | 211 | 8/16/2024 |
8.1.8-preview-03 | 139 | 8/13/2024 |
8.1.8-preview-02 | 115 | 8/13/2024 |
8.1.8-preview-01 | 101 | 8/12/2024 |
8.1.7 | 106 | 8/7/2024 |
8.1.7-preview-09 | 102 | 7/3/2024 |
8.1.7-preview-08 | 96 | 7/2/2024 |
8.1.7-preview-07 | 94 | 6/10/2024 |
8.1.7-preview-06 | 84 | 6/10/2024 |
8.1.7-preview-05 | 121 | 6/6/2024 |
8.1.7-preview-04 | 98 | 6/6/2024 |
8.1.7-preview-03 | 105 | 5/24/2024 |
8.1.7-preview-02 | 96 | 5/10/2024 |
8.1.7-preview-01 | 102 | 5/8/2024 |
8.1.6 | 1,285 | 5/7/2024 |
8.1.6-preview-08 | 72 | 5/2/2024 |
8.1.6-preview-07 | 85 | 4/29/2024 |
8.1.6-preview-06 | 99 | 4/26/2024 |
8.1.6-preview-05 | 109 | 4/24/2024 |
8.1.6-preview-04 | 98 | 4/22/2024 |
8.1.6-preview-03 | 101 | 4/22/2024 |
8.1.6-preview-02 | 88 | 4/17/2024 |
8.1.6-preview-01 | 179 | 4/15/2024 |
8.1.5 | 118 | 4/15/2024 |
8.1.5-preview-15 | 107 | 4/10/2024 |
8.1.5-preview-14 | 128 | 3/20/2024 |
8.1.5-preview-13 | 75 | 3/18/2024 |
8.1.5-preview-12 | 104 | 3/13/2024 |
8.1.5-preview-11 | 75 | 3/13/2024 |
8.1.5-preview-10 | 127 | 3/13/2024 |
8.1.5-preview-09 | 77 | 3/12/2024 |
8.1.5-preview-08 | 101 | 3/12/2024 |
8.1.5-preview-07 | 94 | 3/8/2024 |
8.1.5-preview-06 | 83 | 3/8/2024 |
8.1.5-preview-05 | 94 | 3/7/2024 |
8.1.5-preview-04 | 94 | 3/7/2024 |
8.1.5-preview-03 | 95 | 3/7/2024 |
8.1.5-preview-02 | 87 | 2/28/2024 |
8.1.5-preview-01 | 108 | 2/19/2024 |
8.1.4 | 163 | 2/15/2024 |
8.1.3 | 127 | 2/13/2024 |
8.1.3-preview-07 | 100 | 2/13/2024 |
8.1.3-preview-06 | 102 | 2/12/2024 |
8.1.3-preview-05 | 89 | 2/9/2024 |
8.1.3-preview-04 | 89 | 2/8/2024 |
8.1.3-preview-03 | 109 | 2/7/2024 |
8.1.3-preview-02 | 101 | 2/2/2024 |
8.1.3-preview-01 | 99 | 2/2/2024 |
8.1.2 | 163 | 2/1/2024 |
8.1.2-preview-9 | 112 | 1/22/2024 |
8.1.2-preview-8 | 111 | 1/19/2024 |
8.1.2-preview-7 | 95 | 1/19/2024 |
8.1.2-preview-6 | 93 | 1/19/2024 |
8.1.2-preview-5 | 108 | 1/19/2024 |
8.1.2-preview-4 | 105 | 1/19/2024 |
8.1.2-preview-3 | 94 | 1/18/2024 |
8.1.2-preview-2 | 104 | 1/18/2024 |
8.1.2-preview-16 | 92 | 1/31/2024 |
8.1.2-preview-15 | 108 | 1/31/2024 |
8.1.2-preview-14 | 101 | 1/25/2024 |
8.1.2-preview-13 | 98 | 1/25/2024 |
8.1.2-preview-12 | 97 | 1/23/2024 |
8.1.2-preview-11 | 100 | 1/23/2024 |
8.1.2-preview-10 | 100 | 1/22/2024 |
8.1.2-preview-1 | 93 | 1/18/2024 |
8.1.1 | 141 | 1/18/2024 |
8.1.0 | 117 | 1/18/2024 |
8.0.3 | 169 | 12/29/2023 |
8.0.1 | 155 | 12/14/2023 |
8.0.0 | 161 | 12/7/2023 |
6.0.4.3 | 159 | 12/29/2023 |
6.0.4.2 | 166 | 12/20/2023 |
6.0.4.1 | 234 | 12/19/2023 |
6.0.4 | 173 | 12/4/2023 |
6.0.3.20 | 155 | 11/27/2023 |
6.0.3.19 | 175 | 11/22/2023 |