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

Commit 0e991d4

Browse files
committed
Revert use of explicit converters that prevent APIs from returning null.
1 parent bacf760 commit 0e991d4

12 files changed

+17
-17
lines changed

src/Microsoft.AspNet.Http.Extensions/HeaderDictionaryExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static void AppendCommaSeparatedValues(this IHeaderDictionary headers, st
3636
/// <returns>the associated values from the collection separated into individual values, or StringValues.Empty if the key is not present.</returns>
3737
public static string[] GetCommaSeparatedValues(this IHeaderDictionary headers, string key)
3838
{
39-
return ParsingHelpers.GetHeaderSplit(headers, key).ToArray();
39+
return ParsingHelpers.GetHeaderSplit(headers, key);
4040
}
4141

4242
/// <summary>

src/Microsoft.AspNet.Http.Extensions/HeaderDictionaryTypeExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ internal static T Get<T>(this IHeaderDictionary headers, string name)
179179
if (KnownParsers.TryGetValue(typeof(T), out temp))
180180
{
181181
var func = (Func<string, T>)temp;
182-
return func(headers[name].ToString());
182+
return func(headers[name]);
183183
}
184184

185185
var value = headers[name];
@@ -202,7 +202,7 @@ internal static IList<T> GetList<T>(this IHeaderDictionary headers, string name)
202202
if (KnownListParsers.TryGetValue(typeof(T), out temp))
203203
{
204204
var func = (Func<IList<string>, IList<T>>)temp;
205-
return func(headers[name].ToArray());
205+
return func(headers[name]);
206206
}
207207

208208
var values = headers[name];

src/Microsoft.AspNet.Http.Extensions/Internal/ParsingHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public static void AppendHeaderJoined(IHeaderDictionary headers, string key, par
126126
return;
127127
}
128128

129-
string existing = GetHeader(headers, key).ToString();
129+
string existing = GetHeader(headers, key);
130130
if (existing == null)
131131
{
132132
SetHeaderJoined(headers, key, values);

src/Microsoft.AspNet.Http.Extensions/RequestHeaders.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public HostString Host
170170
{
171171
get
172172
{
173-
return HostString.FromUriComponent(Headers[HeaderNames.Host].ToString());
173+
return HostString.FromUriComponent(Headers[HeaderNames.Host]);
174174
}
175175
set
176176
{

src/Microsoft.AspNet.Http.Extensions/ResponseHeaders.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public Uri Location
134134
get
135135
{
136136
Uri uri;
137-
if (Uri.TryCreate(Headers[HeaderNames.Location].ToString(), UriKind.RelativeOrAbsolute, out uri))
137+
if (Uri.TryCreate(Headers[HeaderNames.Location], UriKind.RelativeOrAbsolute, out uri))
138138
{
139139
return uri;
140140
}

src/Microsoft.AspNet.Http/DefaultHttpRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public override bool IsHttps
140140

141141
public override HostString Host
142142
{
143-
get { return HostString.FromUriComponent(Headers["Host"].ToString()); }
143+
get { return HostString.FromUriComponent(Headers["Host"]); }
144144
set { Headers["Host"] = value.ToUriComponent(); }
145145
}
146146

src/Microsoft.AspNet.Http/DefaultHttpResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public override string ContentType
8787
{
8888
get
8989
{
90-
return Headers[HeaderNames.ContentType].ToString();
90+
return Headers[HeaderNames.ContentType];
9191
}
9292
set
9393
{

src/Microsoft.AspNet.Http/DefaultWebSocketManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public override IList<string> WebSocketRequestedProtocols
5555
{
5656
get
5757
{
58-
return ParsingHelpers.GetHeaderSplit(HttpRequestFeature.Headers, HeaderNames.WebSocketSubProtocols).ToArray();
58+
return ParsingHelpers.GetHeaderSplit(HttpRequestFeature.Headers, HeaderNames.WebSocketSubProtocols);
5959
}
6060
}
6161

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ public FormFile(Stream baseStream, long baseStreamOffset, long length)
2121

2222
public string ContentDisposition
2323
{
24-
get { return Headers["Content-Disposition"].ToString(); }
24+
get { return Headers["Content-Disposition"]; }
2525
set { Headers["Content-Disposition"] = value; }
2626
}
2727

2828
public string ContentType
2929
{
30-
get { return Headers["Content-Type"].ToString(); }
30+
get { return Headers["Content-Type"]; }
3131
set { Headers["Content-Type"] = value; }
3232
}
3333

src/Microsoft.AspNet.Http/RequestCookieCollection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ public string this[string key]
4848

4949
if (Store == null)
5050
{
51-
return string.Empty;
51+
return null;
5252
}
5353

5454
string value;
5555
if (TryGetValue(key, out value))
5656
{
5757
return value;
5858
}
59-
return string.Empty;
59+
return null;
6060
}
6161
}
6262

@@ -126,7 +126,7 @@ public bool TryGetValue(string key, out string value)
126126
{
127127
if (Store == null)
128128
{
129-
value = string.Empty;
129+
value = null;
130130
return false;
131131
}
132132
return Store.TryGetValue(key, out value);

src/Microsoft.AspNet.WebUtilities/MultipartReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private async Task<Dictionary<string, StringValues>> ReadHeadersAsync(Cancellati
8787
throw new InvalidOperationException("Total header size limit exceeded: " + TotalHeaderSizeLimit.ToString());
8888
}
8989
int splitIndex = line.IndexOf(':');
90-
Debug.Assert(splitIndex > 0, $"Invalid header line: {line.ToString()}");
90+
Debug.Assert(splitIndex > 0, $"Invalid header line: {line}");
9191
if (splitIndex >= 0)
9292
{
9393
var name = line.Substring(0, splitIndex);

src/Microsoft.AspNet.WebUtilities/MultipartSection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public string ContentType
1616
StringValues values;
1717
if (Headers.TryGetValue("Content-Type", out values))
1818
{
19-
return values.ToString();
19+
return values;
2020
}
2121
return null;
2222
}
@@ -29,7 +29,7 @@ public string ContentDisposition
2929
StringValues values;
3030
if (Headers.TryGetValue("Content-Disposition", out values))
3131
{
32-
return values.ToString();
32+
return values;
3333
}
3434
return null;
3535
}

0 commit comments

Comments
 (0)