public void SetRequestInformation(IWebInfo webInfo) { this.webRequest.ContentLength = webInfo.ContentLength; this.webRequest.ContentType = webInfo.ContentType; this.webRequest.Method = webInfo.Method.ToString(); this.webRequest.Accept = CopyHeader(HeaderKeys.ACCEPT, webInfo, this.webRequest.Accept); this.webRequest.UserAgent = CopyHeader(HeaderKeys.USER_AGENT, webInfo, this.webRequest.UserAgent); this.webRequest.Timeout = webInfo.Timeout; this.webRequest.ReadWriteTimeout = webInfo.Timeout; }
public string CopyHeader(string key, IWebInfo webInfo, string defaultValue) => webInfo.Headers.AllKeys.Any(m => m.Equals(key, StringComparison.InvariantCultureIgnoreCase)) ? webInfo.Headers[key] : defaultValue;