Skip to content

Commit fd7fb21

Browse files
author
Meyn
committed
Fix WebHeaderCollection copying
1 parent a931892 commit fd7fb21

File tree

3 files changed

+78
-70
lines changed

3 files changed

+78
-70
lines changed
Lines changed: 71 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,81 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFrameworks>net6.0;net7.0;net8.0;</TargetFrameworks>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
<Title>DownloadAssistant</Title>
8-
<PackageId>Shard.DownloadAssistant</PackageId>
9-
<Copyright>Shard © 2025</Copyright>
10-
<PackageProjectUrl></PackageProjectUrl>
11-
<PackageIcon>logo.png</PackageIcon>
12-
<PackageReadmeFile>README.md</PackageReadmeFile>
13-
<Version>1.1.0</Version>
14-
<GenerateDocumentationFile>True</GenerateDocumentationFile>
15-
<Description>A free to use library as a download manager.
16-
Includes retry, priority, cancel, etc.. function.
3+
<PropertyGroup>
4+
<TargetFrameworks>net6.0;net7.0;net8.0;</TargetFrameworks>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
<Title>DownloadAssistant</Title>
8+
<PackageId>Shard.DownloadAssistant</PackageId>
9+
<Copyright>Shard © 2025</Copyright>
10+
<PackageProjectUrl></PackageProjectUrl>
11+
<PackageIcon>logo.png</PackageIcon>
12+
<PackageReadmeFile>README.md</PackageReadmeFile>
13+
<Version>1.1.0</Version>
14+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
15+
<Description>
16+
A free to use library as a download manager.
17+
Includes retry, priority, cancel, etc.. function.
1718

18-
Features:
19-
• StatusRequest: Calls a Head request and returns a response message with the headers.
20-
• SiteRequest: Scans a website for all references.
21-
• GetRequest: To download the response into a file.
22-
• LoadRequest: Extends GetRequest with chunked download.</Description>
23-
<RepositoryType>git</RepositoryType>
24-
<PackageTags>request, FreeToUse, HttpClient, producer-consumer, file-downloader, downloader, chunk, http</PackageTags>
25-
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
26-
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
27-
<Company>Shard</Company>
28-
<Authors>Meyn</Authors>
29-
<PackageReleaseNotes>Easier access to individual progress and speed reporter
30-
Update HttpClient and User Agent Generation
31-
Enhance StatusRequest to Parse Additional Data
32-
Update SiteRequest</PackageReleaseNotes>
33-
<RepositoryUrl>https://github.com/TypNull/DownloadAssistant</RepositoryUrl>
34-
</PropertyGroup>
19+
Features:
20+
• StatusRequest: Calls a Head request and returns a response message with the headers.
21+
• SiteRequest: Scans a website for all references.
22+
• GetRequest: To download the response into a file.
23+
• LoadRequest: Extends GetRequest with chunked download.
24+
</Description>
25+
<RepositoryType>git</RepositoryType>
26+
<PackageTags>request, FreeToUse, HttpClient, producer-consumer, file-downloader, downloader, chunk, http</PackageTags>
27+
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
28+
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
29+
<Company>Shard</Company>
30+
<Authors>Meyn</Authors>
31+
<PackageReleaseNotes>
32+
Easier access to individual progress and speed reporter
33+
Update HttpClient and User Agent Generation
34+
Enhance StatusRequest to Parse Additional Data
35+
Update SiteRequest
36+
</PackageReleaseNotes>
37+
<RepositoryUrl>https://github.com/TypNull/DownloadAssistant</RepositoryUrl>
38+
</PropertyGroup>
3539

36-
<ItemGroup>
37-
<None Include="..\LICENSE.txt">
38-
<Pack>True</Pack>
39-
<PackagePath>\</PackagePath>
40-
</None>
41-
<None Include="..\logo.png">
42-
<Pack>True</Pack>
43-
<PackagePath>\</PackagePath>
44-
</None>
45-
<None Include="..\README.md">
46-
<Pack>True</Pack>
47-
<PackagePath>\</PackagePath>
48-
</None>
49-
</ItemGroup>
40+
<ItemGroup>
41+
<None Include="..\LICENSE.txt">
42+
<Pack>True</Pack>
43+
<PackagePath>\</PackagePath>
44+
</None>
45+
<None Include="..\logo.png">
46+
<Pack>True</Pack>
47+
<PackagePath>\</PackagePath>
48+
</None>
49+
<None Include="..\README.md">
50+
<Pack>True</Pack>
51+
<PackagePath>\</PackagePath>
52+
</None>
53+
</ItemGroup>
5054

51-
<ItemGroup>
52-
<PackageReference Include="Shard.Requests" Version="2.2.1" />
53-
</ItemGroup>
55+
<ItemGroup>
56+
<PackageReference Include="Shard.Requests" Version="2.2.2" />
57+
</ItemGroup>
5458

55-
<ItemGroup>
56-
<Compile Update="Media\MimeTypes.Designer.cs">
57-
<DesignTime>True</DesignTime>
58-
<AutoGen>True</AutoGen>
59-
<DependentUpon>MimeTypes.resx</DependentUpon>
60-
</Compile>
61-
</ItemGroup>
59+
<ItemGroup>
60+
<Compile Update="Media\MimeTypes.Designer.cs">
61+
<DesignTime>True</DesignTime>
62+
<AutoGen>True</AutoGen>
63+
<DependentUpon>MimeTypes.resx</DependentUpon>
64+
</Compile>
65+
</ItemGroup>
6266

63-
<ItemGroup>
64-
<EmbeddedResource Update="Media\MimeTypes.resx">
65-
<Generator>ResXFileCodeGenerator</Generator>
66-
<LastGenOutput>MimeTypes.Designer.cs</LastGenOutput>
67-
</EmbeddedResource>
68-
</ItemGroup>
67+
<ItemGroup>
68+
<EmbeddedResource Update="Media\MimeTypes.resx">
69+
<Generator>ResXFileCodeGenerator</Generator>
70+
<LastGenOutput>MimeTypes.Designer.cs</LastGenOutput>
71+
</EmbeddedResource>
72+
</ItemGroup>
6973

70-
<ItemGroup>
71-
<None Update="logo.png">
72-
<Pack>True</Pack>
73-
<PackagePath>\</PackagePath>
74-
</None>
75-
</ItemGroup>
74+
<ItemGroup>
75+
<None Update="logo.png">
76+
<Pack>True</Pack>
77+
<PackagePath>\</PackagePath>
78+
</None>
79+
</ItemGroup>
7680

7781
</Project>

DownloadAssistant/Options/WebRequestOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected WebRequestOptions(WebRequestOptions<TCompleated> options) : base(optio
4949
Timeout = options.Timeout;
5050
Headers = new();
5151
foreach (string key in options.Headers.AllKeys)
52-
Headers.Add(key, Headers[key]);
52+
Headers.Add(key, options.Headers[key]);
5353
UserAgent = options.UserAgent;
5454
}
5555
}

DownloadAssistant/Requests/WebRequest.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ namespace DownloadAssistant.Requests
3535
protected HttpRequestMessage GetPresetRequestMessage(HttpRequestMessage? httpRequest = null)
3636
{
3737
httpRequest ??= new HttpRequestMessage();
38-
foreach (string key in Options.Headers?.AllKeys ?? Array.Empty<string>())
39-
httpRequest.Headers.Add(key, Options.Headers?[key]);
38+
foreach (string key in Options.Headers.AllKeys ?? Array.Empty<string>())
39+
{
40+
string? headerValue = Options.Headers[key];
41+
if (!string.IsNullOrEmpty(headerValue))
42+
httpRequest.Headers.TryAddWithoutValidation(key, headerValue);
43+
}
4044

4145
if (!string.IsNullOrWhiteSpace(Options.UserAgent))
4246
httpRequest.Headers.Add("User-Agent", Options.UserAgent);

0 commit comments

Comments
 (0)