本文整理汇总了C#中System.Net.Response.ReplaceHeader方法的典型用法代码示例。如果您正苦于以下问题:C# Response.ReplaceHeader方法的具体用法?C# Response.ReplaceHeader怎么用?C# Response.ReplaceHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Response
的用法示例。
在下文中一共展示了Response.ReplaceHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Status
public override Response Status(NameValueCollection httpGet, Request request)
{
Html html = new Html ();
if (httpGet ["delete"] != null) {
int item = int.Parse (httpGet ["delete"]);
using (listLock.Write) {
foreach (RefererPair rp in watchlist.ToArray ()) {
if (rp.GetHashCode () == item)
watchlist.Remove (rp);
}
}
SaveFilters ();
}
if (httpGet ["clear"] != null) {
using (listLock.Write) {
blocked.Clear ();
}
}
if (httpGet ["action"] != null || httpGet ["flags"] != null) {
RefererPair p = new RefererPair (httpGet ["from"], httpGet ["to"]);
p.Flags.Set (httpGet ["flags"]);
if (httpGet ["action"].Contains (" ") == false)
p.Flags.Set (httpGet ["action"]);
using (listLock.Write) {
watchlist.Add (p);
foreach (RefererPair bp in blocked.ToArray ()) {
if (p.Match (bp))
blocked.Remove (bp);
}
}
SaveFilters ();
}
if (httpGet ["return"] != null) {
Response resp = new Response (HttpStatusCode.Redirect, new Html ());
resp.ReplaceHeader ("Location", httpGet ["return"]);
return resp;
}
html += Html.Format (@"<h2>Blocked <a href=""?clear=yes"">clear</a></h2>");
html += Html.Format ("<table><tr><th>From Domain</th><th>To Domain</th><th>Flags</th></tr>");
html += Form ("", "");
using (listLock.Read) {
foreach (RefererPair pair in blocked) {
html += Form (pair);
}
html += Html.Format ("</table>");
html += Html.Format ("<h2>Watchlist</h2>");
html += Html.Format ("<table><tr><th>From Domain</th><th>To Domain</th><th>Flags</th><th>Delete</th></tr>");
foreach (RefererPair pair in watchlist) {
html += Html.Format ("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td><a href=\"?delete={3}\">delete</a></td></tr>", pair.FromHost, pair.ToHost, pair.Flags, pair.GetHashCode ());
}
html += Html.Format ("</table>");
}
html += Html.Format (@"
<div>
<ul>
<li><strong>Pass</strong> Allow request to pass through unmodified</li>
<li><strong>Fake</strong> Change referer to the root of the target host</li>
<li><strong>Clean</strong> Change referer to the root of the source host</li>
<li><strong>Remove</strong> Remove the referer header</li>
<li><strong>Slow</strong> Do not modify the request but slow down the transfer speed</li>
<li><strong>Block</strong> Block the entire request</li>
</ul>
<p>From/To: Wildcard(*) allowed in start of domains, applies to subdomains only</p>
<p>Example: *example.com matches xyz.example.com and example.com but not badexample.com</p>
</div>");
return WebUI.ResponseTemplate (ToString (), html);
}