本文整理汇总了C#中NameValueCollection.FilterHeaders方法的典型用法代码示例。如果您正苦于以下问题:C# NameValueCollection.FilterHeaders方法的具体用法?C# NameValueCollection.FilterHeaders怎么用?C# NameValueCollection.FilterHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NameValueCollection
的用法示例。
在下文中一共展示了NameValueCollection.FilterHeaders方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Map
/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <param name="request"></param>
/// <param name="result"></param>
/// <param name="statusCode"></param>
/// <param name="exception"></param>
/// <returns></returns>
public Attachment Map(string key, HttpWebRequest request, IAsyncResult result, out HttpStatusCode statusCode,
out Exception exception)
{
try
{
var response = request.EndGetResponse(result) as HttpWebResponse;
Stream stream = response.GetResponseStream();
statusCode = response.StatusCode;
exception = null;
var headers = new NameValueCollection();
foreach (string headerKey in response.Headers.AllKeys)
{
headers.Add(headerKey, response.Headers[key]);
}
return new Attachment
{
Data = stream.ReadData(),
Etag = new Guid(response.Headers["ETag"]),
Metadata = headers.FilterHeaders(isServerDocument: false)
};
}
catch (WebException ex)
{
var httpWebResponse = ex.Response as HttpWebResponse;
if (httpWebResponse == null)
{
throw;
}
statusCode = httpWebResponse.StatusCode;
exception = AsyncServerClient.ExtractException(httpWebResponse);
if (httpWebResponse.StatusCode == HttpStatusCode.Conflict)
{
JObject conflictsDoc = JObject.Load(new BsonReader(httpWebResponse.GetResponseStream()));
string[] conflictIds =
conflictsDoc.Value<JArray>("Conflicts").Select(x => x.Value<string>()).ToArray();
throw new ConflictException("Conflict detected on " + key +
", conflict must be resolved before the attachment will be accessible")
{
ConflictedVersionIds = conflictIds
};
}
if (httpWebResponse.StatusCode == HttpStatusCode.NotFound)
{
return null;
}
throw;
}
}