cosmetics

This commit is contained in:
UbitUmarov
2020-05-13 14:51:05 +01:00
parent f15c6be20c
commit 4c7107dfda
2 changed files with 75 additions and 72 deletions

View File

@@ -582,25 +582,36 @@ namespace OpenSim.Framework
/// <summary>
/// Convert a NameValueCollection into a query string. This is the
/// inverse of HttpUtility.ParseQueryString()
/// not exactly the inverse of HttpUtility.ParseQueryString()
/// </summary>
/// <param name="parameters">Collection of key/value pairs to convert</param>
/// <returns>A query string with URL-escaped values</returns>
public static string BuildQueryString(NameValueCollection parameters)
{
List<string> items = new List<string>(parameters.Count);
if (parameters.Count == 0)
return string.Empty;
StringBuilder sb = new StringBuilder(4096);
foreach (string key in parameters.Keys)
{
string[] values = parameters.GetValues(key);
if (values != null)
{
foreach (string value in values)
items.Add(String.Concat(key, "=", HttpUtility.UrlEncode(value ?? String.Empty)));
{
sb.Append(key);
sb.Append("=");
if(!string.IsNullOrWhiteSpace(value))
sb.Append(HttpUtility.UrlEncode(value));
sb.Append("&");
}
}
}
return String.Join("&", items.ToArray());
if(sb.Length > 1)
sb.Length--;
return sb.ToString();
}
/// <summary>
@@ -1097,9 +1108,7 @@ namespace OpenSim.Framework
public class SynchronousRestObjectRequester
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Perform a synchronous REST request.