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

Commit 4354dbb

Browse files
committed
CR use section ContentDisposition and ContentType
1 parent 44fb6c5 commit 4354dbb

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/Microsoft.AspNet.Http/Features/FormFeature.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,16 @@ private async Task<IFormCollection> InnerReadFormAsync(CancellationToken cancell
144144
var section = await multipartReader.ReadNextSectionAsync(cancellationToken);
145145
while (section != null)
146146
{
147-
var headers = section.Headers;
148147
ContentDispositionHeaderValue contentDisposition;
149-
ContentDispositionHeaderValue.TryParse(headers[HeaderNames.ContentDisposition], out contentDisposition);
148+
ContentDispositionHeaderValue.TryParse(section.ContentDisposition, out contentDisposition);
150149
if (HasFileContentDisposition(contentDisposition))
151150
{
152151
// Find the end
153152
await section.Body.DrainAsync(cancellationToken);
154153

155154
var file = new FormFile(_request.Body, section.BaseStreamOffset.Value, section.Body.Length)
156155
{
157-
Headers = new HeaderDictionary(headers),
156+
Headers = new HeaderDictionary(section.Headers),
158157
};
159158
if (files == null)
160159
{
@@ -170,7 +169,7 @@ private async Task<IFormCollection> InnerReadFormAsync(CancellationToken cancell
170169

171170
var key = HeaderUtilities.RemoveQuotes(contentDisposition.Name);
172171
MediaTypeHeaderValue mediaType;
173-
MediaTypeHeaderValue.TryParse(headers[HeaderNames.ContentType], out mediaType);
172+
MediaTypeHeaderValue.TryParse(section.ContentType, out mediaType);
174173
var encoding = FilterEncoding(mediaType?.Encoding);
175174
using (var reader = new StreamReader(section.Body, encoding, detectEncodingFromByteOrderMarks: true, bufferSize: 1024, leaveOpen: true))
176175
{
@@ -180,7 +179,7 @@ private async Task<IFormCollection> InnerReadFormAsync(CancellationToken cancell
180179
}
181180
else
182181
{
183-
System.Diagnostics.Debug.Assert(false, "Unrecognized content-disposition for this section: " + headers[HeaderNames.ContentDisposition]);
182+
System.Diagnostics.Debug.Assert(false, "Unrecognized content-disposition for this section: " + section.ContentDisposition);
184183
}
185184

186185
section = await multipartReader.ReadNextSectionAsync(cancellationToken);

0 commit comments

Comments
 (0)