React to string[] -> StringValues changes.

This commit is contained in:
Chris R 2015-08-28 12:27:17 -07:00
parent 28268ee64b
commit d448c6e389
3 changed files with 11 additions and 8 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts; using System.Diagnostics.Contracts;
using System.IO; using System.IO;
@ -135,14 +136,14 @@ namespace Microsoft.AspNet.TestHost
foreach (var header in request.Headers) foreach (var header in request.Headers)
{ {
serverRequest.Headers.AppendValues(header.Key, header.Value.ToArray()); serverRequest.Headers.Append(header.Key, header.Value.ToArray());
} }
var requestContent = request.Content; var requestContent = request.Content;
if (requestContent != null) if (requestContent != null)
{ {
foreach (var header in request.Content.Headers) foreach (var header in request.Content.Headers)
{ {
serverRequest.Headers.AppendValues(header.Key, header.Value.ToArray()); serverRequest.Headers.Append(header.Key, header.Value.ToArray());
} }
} }
@ -187,9 +188,9 @@ namespace Microsoft.AspNet.TestHost
foreach (var header in HttpContext.Response.Headers) foreach (var header in HttpContext.Response.Headers)
{ {
if (!response.Headers.TryAddWithoutValidation(header.Key, header.Value)) if (!response.Headers.TryAddWithoutValidation(header.Key, (IEnumerable<string>)header.Value))
{ {
bool success = response.Content.Headers.TryAddWithoutValidation(header.Key, header.Value); bool success = response.Content.Headers.TryAddWithoutValidation(header.Key, (IEnumerable<string>)header.Value);
Contract.Assert(success, "Bad header"); Contract.Assert(success, "Bad header");
} }
} }

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Http.Features;
using Microsoft.Framework.Primitives;
namespace Microsoft.AspNet.TestHost namespace Microsoft.AspNet.TestHost
{ {
@ -13,7 +14,7 @@ namespace Microsoft.AspNet.TestHost
public RequestFeature() public RequestFeature()
{ {
Body = Stream.Null; Body = Stream.Null;
Headers = new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase); Headers = new Dictionary<string, StringValues>(StringComparer.OrdinalIgnoreCase);
Method = "GET"; Method = "GET";
Path = ""; Path = "";
PathBase = ""; PathBase = "";
@ -24,7 +25,7 @@ namespace Microsoft.AspNet.TestHost
public Stream Body { get; set; } public Stream Body { get; set; }
public IDictionary<string, string[]> Headers { get; set; } public IDictionary<string, StringValues> Headers { get; set; }
public string Method { get; set; } public string Method { get; set; }

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Http.Features;
using Microsoft.Framework.Primitives;
namespace Microsoft.AspNet.TestHost namespace Microsoft.AspNet.TestHost
{ {
@ -16,7 +17,7 @@ namespace Microsoft.AspNet.TestHost
public ResponseFeature() public ResponseFeature()
{ {
Headers = new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase); Headers = new Dictionary<string, StringValues>(StringComparer.OrdinalIgnoreCase);
Body = new MemoryStream(); Body = new MemoryStream();
// 200 is the default status code all the way down to the host, so we set it // 200 is the default status code all the way down to the host, so we set it
@ -28,7 +29,7 @@ namespace Microsoft.AspNet.TestHost
public string ReasonPhrase { get; set; } public string ReasonPhrase { get; set; }
public IDictionary<string, string[]> Headers { get; set; } public IDictionary<string, StringValues> Headers { get; set; }
public Stream Body { get; set; } public Stream Body { get; set; }