Skip to content

Commit a9f5ae7

Browse files
committed
Merge branch 'release/4.4.0'
2 parents 589a22b + 01a861a commit a9f5ae7

File tree

15 files changed

+283
-111
lines changed

15 files changed

+283
-111
lines changed

.gitignore

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Created with the help of https://www.gitignore.io/api/visualstudio
2-
# Edit at https://www.gitignore.io/?templates=visualstudio
1+
# Created with the help of https://www.toptal.com/developers/gitignore/api/visualstudio (formerly https://www.gitignore.io/api/visualstudio)
2+
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudio
33

44
### VisualStudio ###
55
## Ignore Visual Studio temporary files, build results, and
@@ -33,6 +33,7 @@ bld/
3333
[Bb]in/
3434
[Oo]bj/
3535
[Ll]og/
36+
[Ll]ogs/
3637

3738
# Visual Studio 2015/2017 cache/options directory
3839
.vs/
@@ -72,6 +73,7 @@ StyleCopReport.xml
7273
*_p.c
7374
*_h.h
7475
*.ilk
76+
*.meta
7577
*.obj
7678
*.iobj
7779
*.pch
@@ -129,9 +131,6 @@ _ReSharper*/
129131
*.[Rr]e[Ss]harper
130132
*.DotSettings.user
131133

132-
# JustCode is a .NET coding add-in
133-
.JustCode
134-
135134
# TeamCity is a build add-in
136135
_TeamCity*
137136

@@ -142,6 +141,9 @@ _TeamCity*
142141
.axoCover/*
143142
!.axoCover/settings.json
144143

144+
# Coverlet is a free, cross platform Code Coverage Tool
145+
coverage*[.json, .xml, .info]
146+
145147
# Visual Studio code coverage results
146148
*.coverage
147149
*.coveragexml
@@ -311,7 +313,7 @@ paket-files/
311313
__pycache__/
312314
*.pyc
313315

314-
# Cake - Uncomment if you are using it
316+
# Cake
315317
tools/**
316318
!tools/packages.config
317319

@@ -351,7 +353,10 @@ healthchecksdb
351353
# Backup folder for Package Reference Convert tool in Visual Studio 2017
352354
MigrationBackup/
353355

356+
# Ionide (cross platform F# VS Code tools) working folder
357+
.ionide/
358+
354359
# WinMerge
355360
*.bak
356361

357-
# End of https://www.gitignore.io/api/visualstudio
362+
# End of https://www.toptal.com/developers/gitignore/api/visualstudio

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ The parser was built for and tested on NET 4.6.1, NET 4,7,2 and NETSTANDARD 2.0.
8181
// ==== Advanced Parsing ====
8282
var parser = new StreamingMultipartFormDataParser(stream);
8383
parser.ParameterHandler += parameter => DoSomethingWithParameter(parameter);
84-
parser.FileHandler += (name, fileName, type, disposition, buffer, bytes) =>
84+
parser.FileHandler += (name, fileName, type, disposition, buffer, bytes, partNumber) =>
8585
{
86-
// Write the part of the file we've recieved to a file stream. (Or do something else)
86+
// Write the part of the file we've received to a file stream. (Or do something else)
8787
filestream.Write(buffer, 0, bytes);
8888
}
8989

@@ -154,9 +154,9 @@ The parser was built for and tested on NET 4.6.1, NET 4,7,2 and NETSTANDARD 2.0.
154154
// ==== Advanced Parsing ====
155155
var parser = new StreamingMultipartFormDataParser(stream);
156156
parser.ParameterHandler += parameter => DoSomethingWithParameter(parameter);
157-
parser.FileHandler += (name, fileName, type, disposition, buffer, bytes) =>
157+
parser.FileHandler += (name, fileName, type, disposition, buffer, bytes, partNumber) =>
158158
{
159-
// Write the part of the file we've recieved to a file stream. (Or do something else)
159+
// Write the part of the file we've received to a file stream. (Or do something else)
160160
// Assume that filesreamsByName is a Dictionary<string, FileStream> of all the files
161161
// we are writing.
162162
filestreamsByName[name].Write(buffer, 0, bytes);

Source/HttpMultipartParser.Benchmark/HttpMultipartParser.Benchmark.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp3.0</TargetFramework>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="BenchmarkDotNet" Version="0.12.0" />
9+
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
1010
</ItemGroup>
1111

1212
<ItemGroup>
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
using BenchmarkDotNet.Configs;
12
using BenchmarkDotNet.Running;
23

3-
namespace HttpMultipartParse.Benchmark
4+
namespace HttpMultipartParser.Benchmark
45
{
56
class Program
67
{
7-
static void Main()
8+
static void Main(string[] args)
89
{
9-
BenchmarkRunner.Run(typeof(Program).Assembly);
10+
IConfig config = null;
1011

11-
// To debug:
12-
// BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, new DebugInProcessConfig());
12+
// To debug
13+
// config = new DebugInProcessConfig();
14+
15+
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, config);
1316
}
1417
}
1518
}

Source/HttpMultipartParser.UnitTests/HttpMultipartFormParserUnitTests.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,30 @@ public async Task HandlesFileWithLastCrLfImmediatlyAfterBufferLengthAsync()
190190
var parser = await MultipartFormDataParser.ParseAsync(stream, Encoding.UTF8).ConfigureAwait(false);
191191
}
192192
}
193+
194+
[Fact]
195+
public async Task HandlesFileWithoutFilename()
196+
{
197+
string request =
198+
@"------WebKitFormBoundaryphElSb1aBJGfLyAP
199+
Content-Disposition: form-data; name=""fileName""
200+
201+
Testfile
202+
------WebKitFormBoundaryphElSb1aBJGfLyAP
203+
Content-Disposition: form-data; name=""file""
204+
Content-Type: application/octet-stream
205+
206+
"
207+
+ new string('\0', 8147)
208+
+ @"
209+
------WebKitFormBoundaryphElSb1aBJGfLyAP--
210+
";
211+
212+
using (Stream stream = TestUtil.StringToStream(request, Encoding.UTF8))
213+
{
214+
var parser = await MultipartFormDataParser.ParseAsync(stream, Encoding.UTF8).ConfigureAwait(false);
215+
Assert.Single(parser.Files);
216+
}
217+
}
193218
}
194219
}

Source/HttpMultipartParser.UnitTests/HttpMultipartParser.UnitTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
1111
<PackageReference Include="xunit" Version="2.4.1" />
12-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
1313
<PrivateAssets>all</PrivateAssets>
1414
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1515
</PackageReference>

Source/HttpMultipartParser.UnitTests/ParserScenarios/ExactBufferTruncate.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public ExactBufferTruncate()
4646
}
4747
}
4848

49-
5049
/// <summary>
5150
/// Tests that the final '--' ending up in a seperate chunk doesn't break everything.
5251
/// </summary>
@@ -60,7 +59,6 @@ public void CanHandleFinalDashesInSeperateBufferFromEndBinary()
6059
}
6160
}
6261

63-
6462
/// <summary>
6563
/// Tests that the final '--' ending up in a seperate chunk doesn't break everything.
6664
/// </summary>

Source/HttpMultipartParser/BinaryStreamStack.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ public int Read(byte[] buffer, int index, int count)
197197
return 0;
198198
}
199199

200-
// Read through all the stream untill we exhaust them
201-
// or untill count is satisfied
200+
// Read through all the stream until we exhaust them
201+
// or until count is satisfied
202202
int amountRead = 0;
203203
BinaryReader top = streams.Peek();
204204
while (amountRead < count && streams.Any())
@@ -243,8 +243,8 @@ public int Read(char[] buffer, int index, int count)
243243
return 0;
244244
}
245245

246-
// Read through all the stream untill we exhaust them
247-
// or untill count is satisfied
246+
// Read through all the stream until we exhaust them
247+
// or until count is satisfied
248248
int amountRead = 0;
249249
BinaryReader top = streams.Peek();
250250
while (amountRead < count && streams.Any())

Source/HttpMultipartParser/HttpMultipartParser.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
<ItemGroup>
4040
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
41-
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.3.3" />
41+
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.3.6" />
4242
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
4343
<PackageReference Include="System.Buffers" Version="4.5.1" />
4444
</ItemGroup>

0 commit comments

Comments
 (0)