本文整理汇总了C#中IRestClient.BuildUrl方法的典型用法代码示例。如果您正苦于以下问题:C# IRestClient.BuildUrl方法的具体用法?C# IRestClient.BuildUrl怎么用?C# IRestClient.BuildUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRestClient
的用法示例。
在下文中一共展示了IRestClient.BuildUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMessageAddress
/// <summary>
/// Get the REST requests relative address (for HTTP request message)
/// </summary>
/// <param name="client">REST client</param>
/// <param name="request">REST request</param>
/// <returns>The relative request message URL</returns>
protected virtual Uri GetMessageAddress(IRestClient client, IRestRequest request)
{
var fullUrl = client.BuildUrl(request);
var url = client.BaseUrl.MakeRelativeUri(fullUrl);
return url;
}
示例2: GetDigestHeader
private string GetDigestHeader(IRestClient client, IRestRequest restRequest)
{
_nc = _nc + 1;
var uri = client.BuildUrl(restRequest);
var credential = _credentials.GetCredential(uri, "Digest");
var pathAndQuery = uri.GetComponents(UriComponents.PathAndQuery, UriFormat.SafeUnescaped);
var ha1 = CalculateMd5Hash(string.Format("{0}:{1}:{2}", credential.UserName, _realm, credential.Password));
var ha2 = CalculateMd5Hash(string.Format("{0}:{1}", restRequest.GetEffectiveHttpMethod().Method, pathAndQuery));
var digestResponse = CalculateMd5Hash(string.Format("{0}:{1}:{2:00000000}:{3}:{4}:{5}", ha1, _nonce, _nc, _cnonce, _qop, ha2));
var result = new StringBuilder();
result
.AppendFormat("Digest username=\"{0}\"", credential.UserName)
.AppendFormat(",realm=\"{0}\"", _realm)
.AppendFormat(",nonce=\"{0}\"", _nonce)
.AppendFormat(",uri=\"{0}\"", pathAndQuery)
.AppendFormat(",algorithm=\"{0}\"", "MD5")
.AppendFormat(",cnonce=\"{0}\"", _cnonce)
.AppendFormat(",nc={0:D08}", _nc)
.AppendFormat(",qop=\"{0}\"", _qop);
if (!string.IsNullOrEmpty(_opaque))
result
.AppendFormat(",opaque=\"{0}\"", _opaque);
result
.AppendFormat(",response=\"{0}\"", digestResponse);
return result.ToString();
}