⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 httpauthenticationheader.cs

📁 SharpDevelop2.0.0 c#开发免费工具
💻 CS
字号:
// <file>
//     <copyright see="prj:///doc/copyright.txt"/>
//     <license see="prj:///doc/license.txt"/>
//     <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
//     <version>$Revision: 1005 $</version>
// </file>

using System;
using System.Net;
using System.Text;

namespace ICSharpCode.SharpDevelop.Gui
{
	/// <summary>
	/// Represents the WWW-Authenticate HTTP response header.
	/// </summary>
	public class HttpAuthenticationHeader
	{
		string[] authenticationSchemes;
		
		public HttpAuthenticationHeader(WebHeaderCollection headers)
		{
			authenticationSchemes = headers.GetValues("WWW-Authenticate");
		}
		
		public override string ToString()
		{
			if (HasAuthenticationSchemes) {
				StringBuilder schemes = new StringBuilder();
				foreach (string scheme in authenticationSchemes) {
					schemes.Append("WWW-Authenticate: ");
					schemes.Append(scheme);
					schemes.Append("\r\n");
				}
				return schemes.ToString();
			}
			return String.Empty;
		}
		
		/// <summary>
		/// Gets a comma separated list of authentication types.
		/// </summary>
		public string AuthenticationType {
			get {
				if (HasAuthenticationSchemes) {
					int schemesAdded = 0;
					StringBuilder authenticationType = new StringBuilder();
					for (int i = 0; i < authenticationSchemes.Length; ++i) {
						string scheme = authenticationSchemes[i];
						int index = scheme.IndexOf(' ');
						if (index > 0) {
							scheme = scheme.Substring(0, index);
						}
						if (schemesAdded > 0) {
							authenticationType.Append(",");
						}
						authenticationType.Append(scheme);
						schemesAdded++;
					}
					return authenticationType.ToString();
				}
				return String.Empty;
			}
		}
		
		bool HasAuthenticationSchemes {
			get {
				return authenticationSchemes != null && authenticationSchemes.Length > 0;
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -