本文整理汇总了C#中HttpRequestHeader类的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestHeader类的具体用法?C# HttpRequestHeader怎么用?C# HttpRequestHeader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpRequestHeader类属于命名空间,在下文中一共展示了HttpRequestHeader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1:
// Properties
public string this[HttpRequestHeader reqHeader]
{
get
{
return HeaderStrings[(int)reqHeader];
}
}
示例2: BuildWebRequest_RestrictedTypes_AddsCorrectHeader
public void BuildWebRequest_RestrictedTypes_AddsCorrectHeader(HttpRequestHeader header, string value)
{
request.AddHeader(header, value);
var webrequest = HttpWebRequestBuilder.BuildFrom(request);
Assert.That(webrequest.Headers[header], Is.Not.Null);
}
示例3: ToString
private static string ToString(HttpRequestHeader value)
{
switch (value)
{
case HttpRequestHeader.CacheControl:
return "Cache-Control";
case HttpRequestHeader.KeepAlive:
return "Keep-Alive";
case HttpRequestHeader.TransferEncoding:
return "Transfer-Encoding";
case HttpRequestHeader.ContentLength:
return "Content-Length";
case HttpRequestHeader.ContentType:
return "Content-Type";
case HttpRequestHeader.ContentEncoding:
return "Content-Encoding";
case HttpRequestHeader.ContentLanguage:
return "Content-Language";
case HttpRequestHeader.ContentLocation:
return "Content-Location";
case HttpRequestHeader.ContentMd5:
return "Content-MD5";
case HttpRequestHeader.ContentRange:
return "Content-Range";
case HttpRequestHeader.LastModified:
return "Last-Modified";
case HttpRequestHeader.AcceptCharset:
return "Accept-Charset";
case HttpRequestHeader.AcceptEncoding:
return "Accept-Encoding";
case HttpRequestHeader.AcceptLanguage:
return "Accept-Language";
case HttpRequestHeader.IfMatch:
return "If-Match";
case HttpRequestHeader.IfModifiedSince:
return "If-Modified-Since";
case HttpRequestHeader.IfNoneMatch:
return "If-None-Match";
case HttpRequestHeader.IfRange:
return "If-Range";
case HttpRequestHeader.IfUnmodifiedSince:
return "If-Unmodified-Since";
case HttpRequestHeader.MaxForwards:
return "Max-Forwards";
case HttpRequestHeader.ProxyAuthorization:
return "Proxy-Authorization";
case HttpRequestHeader.UserAgent:
return "User-Agent";
default:
return value.ToString();
}
}
示例4: InvalidOperationException
public string this[HttpRequestHeader header]
{
get
{
if (!AllowHttpRequestHeader)
{
throw new InvalidOperationException(SR.net_headers_req);
}
return this[header.GetName()];
}
set
{
if (!AllowHttpRequestHeader)
{
throw new InvalidOperationException(SR.net_headers_req);
}
this[header.GetName()] = value;
}
}
示例5: IsValidHeader
bool IsValidHeader (HttpRequestHeader header)
{
switch (header) {
case HttpRequestHeader.Connection:
case HttpRequestHeader.Date:
case HttpRequestHeader.KeepAlive:
case HttpRequestHeader.Trailer:
case HttpRequestHeader.TransferEncoding:
case HttpRequestHeader.Upgrade:
case HttpRequestHeader.Via:
case HttpRequestHeader.Warning:
case HttpRequestHeader.Allow:
case HttpRequestHeader.ContentLength:
case HttpRequestHeader.ContentType:
case HttpRequestHeader.ContentLocation:
case HttpRequestHeader.ContentRange:
case HttpRequestHeader.LastModified:
case HttpRequestHeader.Accept:
case HttpRequestHeader.AcceptCharset:
case HttpRequestHeader.AcceptEncoding:
case HttpRequestHeader.AcceptLanguage:
// Authorization was not valid before SL4
// case HttpRequestHeader.Authorization:
case HttpRequestHeader.Cookie:
case HttpRequestHeader.Expect:
case HttpRequestHeader.Host:
case HttpRequestHeader.IfModifiedSince:
case HttpRequestHeader.MaxForwards:
// ProxyAuthorization was not valid before SL4
// case HttpRequestHeader.ProxyAuthorization:
case HttpRequestHeader.Referer:
case HttpRequestHeader.Te:
// Range was not valid in SL2 but is accepted in SL3
// case HttpRequestHeader.Range:
case HttpRequestHeader.UserAgent:
return false;
default:
return true;
}
}
示例6: Get
public string this[HttpRequestHeader hrh]
{
get {
return Get (RequestHeaderToString (hrh));
}
set {
Add (RequestHeaderToString (hrh), value);
}
}
示例7: RequestHeaderToString
string RequestHeaderToString (HttpRequestHeader value)
{
switch (value){
case HttpRequestHeader.CacheControl:
return "cache-control";
case HttpRequestHeader.Connection:
return "connection";
case HttpRequestHeader.Date:
return "date";
case HttpRequestHeader.KeepAlive:
return "keep-alive";
case HttpRequestHeader.Pragma:
return "pragma";
case HttpRequestHeader.Trailer:
return "trailer";
case HttpRequestHeader.TransferEncoding:
return "transfer-encoding";
case HttpRequestHeader.Upgrade:
return "upgrade";
case HttpRequestHeader.Via:
return "via";
case HttpRequestHeader.Warning:
return "warning";
case HttpRequestHeader.Allow:
return "allow";
case HttpRequestHeader.ContentLength:
return "content-length";
case HttpRequestHeader.ContentType:
return "content-type";
case HttpRequestHeader.ContentEncoding:
return "content-encoding";
case HttpRequestHeader.ContentLanguage:
return "content-language";
case HttpRequestHeader.ContentLocation:
return "content-location";
case HttpRequestHeader.ContentMd5:
return "content-md5";
case HttpRequestHeader.ContentRange:
return "content-range";
case HttpRequestHeader.Expires:
return "expires";
case HttpRequestHeader.LastModified:
return "last-modified";
case HttpRequestHeader.Accept:
return "accept";
case HttpRequestHeader.AcceptCharset:
return "accept-charset";
case HttpRequestHeader.AcceptEncoding:
return "accept-encoding";
case HttpRequestHeader.AcceptLanguage:
return "accept-language";
case HttpRequestHeader.Authorization:
return "authorization";
case HttpRequestHeader.Cookie:
return "cookie";
case HttpRequestHeader.Expect:
return "expect";
case HttpRequestHeader.From:
return "from";
case HttpRequestHeader.Host:
return "host";
case HttpRequestHeader.IfMatch:
return "if-match";
case HttpRequestHeader.IfModifiedSince:
return "if-modified-since";
case HttpRequestHeader.IfNoneMatch:
return "if-none-match";
case HttpRequestHeader.IfRange:
return "if-range";
case HttpRequestHeader.IfUnmodifiedSince:
return "if-unmodified-since";
case HttpRequestHeader.MaxForwards:
return "max-forwards";
case HttpRequestHeader.ProxyAuthorization:
return "proxy-authorization";
case HttpRequestHeader.Referer:
return "referer";
case HttpRequestHeader.Range:
return "range";
case HttpRequestHeader.Te:
return "te";
case HttpRequestHeader.Translate:
return "translate";
case HttpRequestHeader.UserAgent:
return "user-agent";
default:
throw new InvalidOperationException ();
}
}
示例8: AddHeader
public void AddHeader(HttpRequestHeader headerType, string value)
{
_headers.Add(headerType, value);
}
示例9: SetHeaderValue
private void SetHeaderValue(HttpRequestHeader name, string value)
{
if (value != null)
{
_headers[name] = value;
}
else
{
_headers.Remove(name);
}
}
示例10: GetKnownHeader
private string GetKnownHeader(HttpRequestHeader header)
{
return Interop.HttpApi.GetKnownHeader(RequestBuffer, OriginalBlobAddress, (int)header);
}
示例11: HeaderValueAttribute
public HeaderValueAttribute(HttpRequestHeader header)
{
_headerName = HttpRequestHeaders.HeaderNameFor(header);
}
示例12: Add
public static void Add(this WebHeaderCollection col, HttpRequestHeader key, string value)
{
col[key] = value;
}
示例13: Add
public void Add(HttpRequestHeader header, string value) { }
示例14: Remove
public void Remove(HttpRequestHeader header) { }
示例15: HttpRequestHeaderToString
public string this [HttpRequestHeader header] {
get { return this [HttpRequestHeaderToString (header)]; }
set {
string h = HttpRequestHeaderToString (header);
if (validate)
ValidateHeader (h);
headers [h] = value;
}
}