Nexus.Client.Util.Downloader.FileMetadata.Initialize C# (CSharp) Méthode

Initialize() private méthode

Loads the file metadata from the given HTTP headers.
private Initialize ( WebHeaderCollection p_whcFileHeader ) : void
p_whcFileHeader System.Net.WebHeaderCollection The HTTP header collection containing the file's metadata.
Résultat void
		private void Initialize(WebHeaderCollection p_whcFileHeader)
		{
			foreach (string strKey in p_whcFileHeader.Keys)
			{
				switch (strKey)
				{
					case "Content-Disposition":
						Regex rgxFilename = new Regex("filename=([^;]+)");
						Match mchFilename = rgxFilename.Match(p_whcFileHeader.GetValues(strKey)[0]);
						if (mchFilename.Success)
							SuggestedFileName = mchFilename.Groups[1].Value.Trim("\"".ToCharArray());
						break;
					case "Content-Length":
						if (Length == 0)
							Length = UInt64.Parse(p_whcFileHeader.GetValues(strKey)[0]);
						break;
					case "Content-Type":
						IsHtml = p_whcFileHeader.GetValues(strKey)[0].Equals("text/html", StringComparison.OrdinalIgnoreCase);
						break;
					case "Accept-Ranges":
					case "Content-Range":
						string strValue = p_whcFileHeader.GetValues(strKey)[0];
						SupportsResume |= strValue.Contains("bytes");
						if (strKey.Equals("Content-Range") && !String.IsNullOrEmpty(strValue))
						{
							string[] strRange = strValue.Split(' ', '-', '/');
							if (strRange[0].Equals("bytes"))
								Length = UInt64.Parse(strRange[3]);
						}
						break;
					case "ETag":
						ETag = p_whcFileHeader.GetValues(strKey)[0];
						break;
					case "NexusError":
						NexusError = p_whcFileHeader.GetValues(strKey)[0];
						break;
					case "NexusErrorInfo":
						NexusErrorInfo = p_whcFileHeader.GetValues(strKey)[0];
						break;
					default:
						Other[strKey] = p_whcFileHeader.GetValues(strKey);
						break;
				}
			}
		}
	}