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

Commit

Permalink
Revert use of explicit converters that prevent APIs from returning null.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher committed Nov 4, 2015
1 parent bacf760 commit 0e991d4
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void AppendCommaSeparatedValues(this IHeaderDictionary headers, st
/// <returns>the associated values from the collection separated into individual values, or StringValues.Empty if the key is not present.</returns>
public static string[] GetCommaSeparatedValues(this IHeaderDictionary headers, string key)
{
return ParsingHelpers.GetHeaderSplit(headers, key).ToArray();
return ParsingHelpers.GetHeaderSplit(headers, key);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ internal static T Get<T>(this IHeaderDictionary headers, string name)
if (KnownParsers.TryGetValue(typeof(T), out temp))
{
var func = (Func<string, T>)temp;
return func(headers[name].ToString());
return func(headers[name]);
}

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

var values = headers[name];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static void AppendHeaderJoined(IHeaderDictionary headers, string key, par
return;
}

string existing = GetHeader(headers, key).ToString();
string existing = GetHeader(headers, key);
if (existing == null)
{
SetHeaderJoined(headers, key, values);
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.AspNet.Http.Extensions/RequestHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public HostString Host
{
get
{
return HostString.FromUriComponent(Headers[HeaderNames.Host].ToString());
return HostString.FromUriComponent(Headers[HeaderNames.Host]);
}
set
{
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.AspNet.Http.Extensions/ResponseHeaders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public Uri Location
get
{
Uri uri;
if (Uri.TryCreate(Headers[HeaderNames.Location].ToString(), UriKind.RelativeOrAbsolute, out uri))
if (Uri.TryCreate(Headers[HeaderNames.Location], UriKind.RelativeOrAbsolute, out uri))
{
return uri;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.AspNet.Http/DefaultHttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public override bool IsHttps

public override HostString Host
{
get { return HostString.FromUriComponent(Headers["Host"].ToString()); }
get { return HostString.FromUriComponent(Headers["Host"]); }
set { Headers["Host"] = value.ToUriComponent(); }
}

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.AspNet.Http/DefaultHttpResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public override string ContentType
{
get
{
return Headers[HeaderNames.ContentType].ToString();
return Headers[HeaderNames.ContentType];
}
set
{
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.AspNet.Http/DefaultWebSocketManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public override IList<string> WebSocketRequestedProtocols
{
get
{
return ParsingHelpers.GetHeaderSplit(HttpRequestFeature.Headers, HeaderNames.WebSocketSubProtocols).ToArray();
return ParsingHelpers.GetHeaderSplit(HttpRequestFeature.Headers, HeaderNames.WebSocketSubProtocols);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.AspNet.Http/Features/FormFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public FormFile(Stream baseStream, long baseStreamOffset, long length)

public string ContentDisposition
{
get { return Headers["Content-Disposition"].ToString(); }
get { return Headers["Content-Disposition"]; }
set { Headers["Content-Disposition"] = value; }
}

public string ContentType
{
get { return Headers["Content-Type"].ToString(); }
get { return Headers["Content-Type"]; }
set { Headers["Content-Type"] = value; }
}

Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.AspNet.Http/RequestCookieCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public string this[string key]

if (Store == null)
{
return string.Empty;
return null;
}

string value;
if (TryGetValue(key, out value))
{
return value;
}
return string.Empty;
return null;
}
}

Expand Down Expand Up @@ -126,7 +126,7 @@ public bool TryGetValue(string key, out string value)
{
if (Store == null)
{
value = string.Empty;
value = null;
return false;
}
return Store.TryGetValue(key, out value);
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.AspNet.WebUtilities/MultipartReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private async Task<Dictionary<string, StringValues>> ReadHeadersAsync(Cancellati
throw new InvalidOperationException("Total header size limit exceeded: " + TotalHeaderSizeLimit.ToString());
}
int splitIndex = line.IndexOf(':');
Debug.Assert(splitIndex > 0, $"Invalid header line: {line.ToString()}");
Debug.Assert(splitIndex > 0, $"Invalid header line: {line}");
if (splitIndex >= 0)
{
var name = line.Substring(0, splitIndex);
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.AspNet.WebUtilities/MultipartSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public string ContentType
StringValues values;
if (Headers.TryGetValue("Content-Type", out values))
{
return values.ToString();
return values;
}
return null;
}
Expand All @@ -29,7 +29,7 @@ public string ContentDisposition
StringValues values;
if (Headers.TryGetValue("Content-Disposition", out values))
{
return values.ToString();
return values;
}
return null;
}
Expand Down

0 comments on commit 0e991d4

Please sign in to comment.