Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 686829d

Browse files
author
Nate McMaster
committed
Add tests for WritableBuffer extensions and rename WriteAscii => WriteAsciiNoValidation
1 parent 7f78558 commit 686829d

File tree

9 files changed

+250
-40
lines changed

9 files changed

+250
-40
lines changed

src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/FrameHeaders.Generated.cs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7772,7 +7772,7 @@ protected void CopyToFast(ref WritableBuffer output)
77727772
if (value != null)
77737773
{
77747774
output.WriteFast(_headerBytes, 17, 14);
7775-
output.WriteAscii(value);
7775+
output.WriteAsciiNoValidation(value);
77767776
}
77777777
}
77787778
}
@@ -7798,7 +7798,7 @@ protected void CopyToFast(ref WritableBuffer output)
77987798
if (value != null)
77997799
{
78007800
output.WriteFast(_headerBytes, 31, 8);
7801-
output.WriteAscii(value);
7801+
output.WriteAsciiNoValidation(value);
78027802
}
78037803
}
78047804
}
@@ -7819,7 +7819,7 @@ protected void CopyToFast(ref WritableBuffer output)
78197819
if (value != null)
78207820
{
78217821
output.WriteFast(_headerBytes, 133, 16);
7822-
output.WriteAscii(value);
7822+
output.WriteAsciiNoValidation(value);
78237823
}
78247824
}
78257825
}
@@ -7845,7 +7845,7 @@ protected void CopyToFast(ref WritableBuffer output)
78457845
if (value != null)
78467846
{
78477847
output.WriteFast(_headerBytes, 350, 10);
7848-
output.WriteAscii(value);
7848+
output.WriteAsciiNoValidation(value);
78497849
}
78507850
}
78517851
}
@@ -7877,7 +7877,7 @@ protected void CopyToFast(ref WritableBuffer output)
78777877
if (value != null)
78787878
{
78797879
output.WriteFast(_headerBytes, 0, 17);
7880-
output.WriteAscii(value);
7880+
output.WriteAsciiNoValidation(value);
78817881
}
78827882
}
78837883
}
@@ -7898,7 +7898,7 @@ protected void CopyToFast(ref WritableBuffer output)
78987898
if (value != null)
78997899
{
79007900
output.WriteFast(_headerBytes, 39, 14);
7901-
output.WriteAscii(value);
7901+
output.WriteAsciiNoValidation(value);
79027902
}
79037903
}
79047904
}
@@ -7919,7 +7919,7 @@ protected void CopyToFast(ref WritableBuffer output)
79197919
if (value != null)
79207920
{
79217921
output.WriteFast(_headerBytes, 53, 10);
7922-
output.WriteAscii(value);
7922+
output.WriteAsciiNoValidation(value);
79237923
}
79247924
}
79257925
}
@@ -7940,7 +7940,7 @@ protected void CopyToFast(ref WritableBuffer output)
79407940
if (value != null)
79417941
{
79427942
output.WriteFast(_headerBytes, 63, 11);
7943-
output.WriteAscii(value);
7943+
output.WriteAsciiNoValidation(value);
79447944
}
79457945
}
79467946
}
@@ -7966,7 +7966,7 @@ protected void CopyToFast(ref WritableBuffer output)
79667966
if (value != null)
79677967
{
79687968
output.WriteFast(_headerBytes, 74, 21);
7969-
output.WriteAscii(value);
7969+
output.WriteAsciiNoValidation(value);
79707970
}
79717971
}
79727972
}
@@ -7987,7 +7987,7 @@ protected void CopyToFast(ref WritableBuffer output)
79877987
if (value != null)
79887988
{
79897989
output.WriteFast(_headerBytes, 95, 11);
7990-
output.WriteAscii(value);
7990+
output.WriteAsciiNoValidation(value);
79917991
}
79927992
}
79937993
}
@@ -8008,7 +8008,7 @@ protected void CopyToFast(ref WritableBuffer output)
80088008
if (value != null)
80098009
{
80108010
output.WriteFast(_headerBytes, 106, 7);
8011-
output.WriteAscii(value);
8011+
output.WriteAsciiNoValidation(value);
80128012
}
80138013
}
80148014
}
@@ -8029,7 +8029,7 @@ protected void CopyToFast(ref WritableBuffer output)
80298029
if (value != null)
80308030
{
80318031
output.WriteFast(_headerBytes, 113, 11);
8032-
output.WriteAscii(value);
8032+
output.WriteAsciiNoValidation(value);
80338033
}
80348034
}
80358035
}
@@ -8050,7 +8050,7 @@ protected void CopyToFast(ref WritableBuffer output)
80508050
if (value != null)
80518051
{
80528052
output.WriteFast(_headerBytes, 124, 9);
8053-
output.WriteAscii(value);
8053+
output.WriteAsciiNoValidation(value);
80548054
}
80558055
}
80568056
}
@@ -8071,7 +8071,7 @@ protected void CopyToFast(ref WritableBuffer output)
80718071
if (value != null)
80728072
{
80738073
output.WriteFast(_headerBytes, 149, 20);
8074-
output.WriteAscii(value);
8074+
output.WriteAsciiNoValidation(value);
80758075
}
80768076
}
80778077
}
@@ -8092,7 +8092,7 @@ protected void CopyToFast(ref WritableBuffer output)
80928092
if (value != null)
80938093
{
80948094
output.WriteFast(_headerBytes, 169, 20);
8095-
output.WriteAscii(value);
8095+
output.WriteAsciiNoValidation(value);
80968096
}
80978097
}
80988098
}
@@ -8113,7 +8113,7 @@ protected void CopyToFast(ref WritableBuffer output)
81138113
if (value != null)
81148114
{
81158115
output.WriteFast(_headerBytes, 189, 20);
8116-
output.WriteAscii(value);
8116+
output.WriteAsciiNoValidation(value);
81178117
}
81188118
}
81198119
}
@@ -8134,7 +8134,7 @@ protected void CopyToFast(ref WritableBuffer output)
81348134
if (value != null)
81358135
{
81368136
output.WriteFast(_headerBytes, 209, 15);
8137-
output.WriteAscii(value);
8137+
output.WriteAsciiNoValidation(value);
81388138
}
81398139
}
81408140
}
@@ -8155,7 +8155,7 @@ protected void CopyToFast(ref WritableBuffer output)
81558155
if (value != null)
81568156
{
81578157
output.WriteFast(_headerBytes, 224, 17);
8158-
output.WriteAscii(value);
8158+
output.WriteAsciiNoValidation(value);
81598159
}
81608160
}
81618161
}
@@ -8176,7 +8176,7 @@ protected void CopyToFast(ref WritableBuffer output)
81768176
if (value != null)
81778177
{
81788178
output.WriteFast(_headerBytes, 241, 11);
8179-
output.WriteAscii(value);
8179+
output.WriteAsciiNoValidation(value);
81808180
}
81818181
}
81828182
}
@@ -8197,7 +8197,7 @@ protected void CopyToFast(ref WritableBuffer output)
81978197
if (value != null)
81988198
{
81998199
output.WriteFast(_headerBytes, 252, 17);
8200-
output.WriteAscii(value);
8200+
output.WriteAsciiNoValidation(value);
82018201
}
82028202
}
82038203
}
@@ -8218,7 +8218,7 @@ protected void CopyToFast(ref WritableBuffer output)
82188218
if (value != null)
82198219
{
82208220
output.WriteFast(_headerBytes, 269, 17);
8221-
output.WriteAscii(value);
8221+
output.WriteAsciiNoValidation(value);
82228222
}
82238223
}
82248224
}
@@ -8239,7 +8239,7 @@ protected void CopyToFast(ref WritableBuffer output)
82398239
if (value != null)
82408240
{
82418241
output.WriteFast(_headerBytes, 286, 7);
8242-
output.WriteAscii(value);
8242+
output.WriteAsciiNoValidation(value);
82438243
}
82448244
}
82458245
}
@@ -8260,7 +8260,7 @@ protected void CopyToFast(ref WritableBuffer output)
82608260
if (value != null)
82618261
{
82628262
output.WriteFast(_headerBytes, 293, 8);
8263-
output.WriteAscii(value);
8263+
output.WriteAsciiNoValidation(value);
82648264
}
82658265
}
82668266
}
@@ -8281,7 +8281,7 @@ protected void CopyToFast(ref WritableBuffer output)
82818281
if (value != null)
82828282
{
82838283
output.WriteFast(_headerBytes, 301, 12);
8284-
output.WriteAscii(value);
8284+
output.WriteAsciiNoValidation(value);
82858285
}
82868286
}
82878287
}
@@ -8302,7 +8302,7 @@ protected void CopyToFast(ref WritableBuffer output)
83028302
if (value != null)
83038303
{
83048304
output.WriteFast(_headerBytes, 313, 22);
8305-
output.WriteAscii(value);
8305+
output.WriteAsciiNoValidation(value);
83068306
}
83078307
}
83088308
}
@@ -8323,7 +8323,7 @@ protected void CopyToFast(ref WritableBuffer output)
83238323
if (value != null)
83248324
{
83258325
output.WriteFast(_headerBytes, 335, 15);
8326-
output.WriteAscii(value);
8326+
output.WriteAsciiNoValidation(value);
83278327
}
83288328
}
83298329
}
@@ -8344,7 +8344,7 @@ protected void CopyToFast(ref WritableBuffer output)
83448344
if (value != null)
83458345
{
83468346
output.WriteFast(_headerBytes, 360, 14);
8347-
output.WriteAscii(value);
8347+
output.WriteAsciiNoValidation(value);
83488348
}
83498349
}
83508350
}
@@ -8365,7 +8365,7 @@ protected void CopyToFast(ref WritableBuffer output)
83658365
if (value != null)
83668366
{
83678367
output.WriteFast(_headerBytes, 374, 8);
8368-
output.WriteAscii(value);
8368+
output.WriteAsciiNoValidation(value);
83698369
}
83708370
}
83718371
}
@@ -8386,7 +8386,7 @@ protected void CopyToFast(ref WritableBuffer output)
83868386
if (value != null)
83878387
{
83888388
output.WriteFast(_headerBytes, 382, 20);
8389-
output.WriteAscii(value);
8389+
output.WriteAsciiNoValidation(value);
83908390
}
83918391
}
83928392
}
@@ -8407,7 +8407,7 @@ protected void CopyToFast(ref WritableBuffer output)
84078407
if (value != null)
84088408
{
84098409
output.WriteFast(_headerBytes, 402, 36);
8410-
output.WriteAscii(value);
8410+
output.WriteAsciiNoValidation(value);
84118411
}
84128412
}
84138413
}
@@ -8428,7 +8428,7 @@ protected void CopyToFast(ref WritableBuffer output)
84288428
if (value != null)
84298429
{
84308430
output.WriteFast(_headerBytes, 438, 32);
8431-
output.WriteAscii(value);
8431+
output.WriteAsciiNoValidation(value);
84328432
}
84338433
}
84348434
}
@@ -8449,7 +8449,7 @@ protected void CopyToFast(ref WritableBuffer output)
84498449
if (value != null)
84508450
{
84518451
output.WriteFast(_headerBytes, 470, 32);
8452-
output.WriteAscii(value);
8452+
output.WriteAsciiNoValidation(value);
84538453
}
84548454
}
84558455
}
@@ -8470,7 +8470,7 @@ protected void CopyToFast(ref WritableBuffer output)
84708470
if (value != null)
84718471
{
84728472
output.WriteFast(_headerBytes, 502, 31);
8473-
output.WriteAscii(value);
8473+
output.WriteAsciiNoValidation(value);
84748474
}
84758475
}
84768476
}
@@ -8491,7 +8491,7 @@ protected void CopyToFast(ref WritableBuffer output)
84918491
if (value != null)
84928492
{
84938493
output.WriteFast(_headerBytes, 533, 33);
8494-
output.WriteAscii(value);
8494+
output.WriteAsciiNoValidation(value);
84958495
}
84968496
}
84978497
}
@@ -8512,7 +8512,7 @@ protected void CopyToFast(ref WritableBuffer output)
85128512
if (value != null)
85138513
{
85148514
output.WriteFast(_headerBytes, 566, 26);
8515-
output.WriteAscii(value);
8515+
output.WriteAsciiNoValidation(value);
85168516
}
85178517
}
85188518
}

src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/FrameResponseHeaders.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public void CopyTo(ref WritableBuffer output)
4646
if (value != null)
4747
{
4848
output.WriteFast(_CrLf);
49-
output.WriteAscii(kv.Key);
49+
output.WriteAsciiNoValidation(kv.Key);
5050
output.WriteFast(_colonSpace);
51-
output.WriteAscii(value);
51+
output.WriteAsciiNoValidation(value);
5252
}
5353
}
5454
}

src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/PipelineExtensions.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,15 @@ private static unsafe void WriteMultiBuffer(this WritableBuffer buffer, byte[] s
158158
}
159159
}
160160

161-
public unsafe static void WriteAscii(this WritableBuffer buffer, string data)
161+
/// <summary>
162+
/// Write string characters as ASCII without validating that characters fall in the ASCII range
163+
/// </summary>
164+
/// <remarks>
165+
/// ASCII character validation is done by <see cref="FrameHeaders.ValidateHeaderCharacters(string)"/>
166+
/// </remarks>
167+
/// <param name="buffer">the buffer</param>
168+
/// <param name="data">The string to write</param>
169+
public unsafe static void WriteAsciiNoValidation(this WritableBuffer buffer, string data)
162170
{
163171
if (string.IsNullOrEmpty(data))
164172
{

test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<ItemGroup>
1414
<Compile Include="..\shared\**\*.cs" />
1515
<Content Include="..\shared\TestResources\testCert.pfx" CopyToOutputDirectory="PreserveNewest" />
16+
<None Update="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
1617
</ItemGroup>
1718

1819
<ItemGroup>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "http://json.schemastore.org/xunit.runner.schema",
3+
"methodDisplay": "method",
4+
"longRunningTestSeconds": 60
5+
}

0 commit comments

Comments
 (0)