本文整理汇总了C#中System.Net.WebHeaderCollection.Set方法的典型用法代码示例。如果您正苦于以下问题:C# WebHeaderCollection.Set方法的具体用法?C# WebHeaderCollection.Set怎么用?C# WebHeaderCollection.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.WebHeaderCollection
的用法示例。
在下文中一共展示了WebHeaderCollection.Set方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyHeaderIsLegal
private bool VerifyHeaderIsLegal(WebHeaderCollection wrc, string header, string content, Type exceptionType)
{
bool res = true;
try
{
Log.Comment("Set Headers Properties for header: '" + header + "', with value: '" + content + "'");
wrc.Set(header, content);
}
catch (Exception ex)
{
Log.Exception("Exception thrown for legal header: '" + header + "'", ex);
res = false;
}
return res;
}
示例2: VerifyHeaderIsIllegal
private bool VerifyHeaderIsIllegal( WebHeaderCollection wrc, string header, string content, Type exceptionType )
{
bool res = true;
try
{
Log.Comment("Set Headers Properties for header: '" + header + "', with value: '" + content + "'");
wrc.Set(header, content);
Log.Comment("Illegal header was set: Failed.");
res = false;
}
catch (Exception ex)
{
if (!HttpTests.ValidateException(ex, exceptionType))
{
res = false;
}
}
return res;
}
示例3: GetWebHeaderCollection
public static WebHeaderCollection GetWebHeaderCollection(Dictionary<string, string> parameters)
{
var headers = new WebHeaderCollection();
foreach (var pair in parameters)
{
headers.Set(pair.Key, pair.Value);
}
return headers;
}
示例4: Request
private JObject Request(string host, string relativeUrl, IDictionary<string, string> post_params)
{
string uri = String.Format("https://{0}{1}", host, relativeUrl);
string clientDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
string auth = GetAuthCode(host, relativeUrl, clientDate, post_params);
// Custom Headers
var customHeaders = new WebHeaderCollection();
if (Plattform == QuizDuellPlattform.ANDROID) { customHeaders.Set("dt", "a"); }
if (Plattform == QuizDuellPlattform.ANDROID) { customHeaders.Set("Accept-Encoding", "identity"); }
customHeaders.Set("Authorization", auth);
customHeaders.Set("clientdate", clientDate);
string responseText = "{}";
if (post_params != null)
{
// Post Request
string postData = DictionaryToPostDataString(post_params);
responseText = Client.MakeRequest(uri, "", postData, customHeaders);
}
else
{
// Get Request
responseText = Client.MakeRequest(uri, "", customHeaders);
}
// Make sure that we have a valid JSON Object
if (responseText == null || responseText.Contains("ACCESS NOT OK") || responseText.Contains("Error"))
{
// responseText = "{\"error\": \"ACCESS NOT OK\"}";
responseText = "{\"error\": \"" + responseText + "\"}";
}
var jObject = JObject.Parse(responseText);
return jObject;
}
示例5: AddHeaders
/// <summary>
/// Allows the subclasses to add their own header information
/// </summary>
/// <param name="webHeaderCollection">The HTTP request headers</param>
internal virtual void AddHeaders(WebHeaderCollection webHeaderCollection)
{
if (!string.IsNullOrEmpty(this.AnchorMailbox))
{
webHeaderCollection.Set(AnchorMailboxHeaderName, this.AnchorMailbox);
webHeaderCollection.Set(ExplicitLogonUserHeaderName, this.AnchorMailbox);
}
}