NetWrok.HTTP.Request.AddHeadersToRequest C# (CSharp) Method

AddHeadersToRequest() private method

private AddHeadersToRequest ( ) : void
return void
        void AddHeadersToRequest()
        {
            if (useCache) {
                string etag = "";
                if (etags.TryGetValue (uri.AbsoluteUri, out etag)) {
                    headers.Set ("If-None-Match", etag);
                }
            }
            var hostHeader = uri.Host;
            if (uri.Port != 80 && uri.Port != 443) {
                hostHeader += ":" + uri.Port.ToString ();
            }
            headers.Set ("Host", hostHeader);
            if(!headers.Contains("User-Agent")) {
                headers.Add("User-Agent", "UniWeb (http://www.differentmethods.com)");
            }

            if (acceptGzip) {
                headers.Set ("Accept-Encoding", "gzip");
            }

            if (enableCookies && uri != null) {
                try {
                    var c = cookies.GetCookieHeader (uri);
                    if (c != null && c.Length > 0) {
                        headers.Set ("Cookie", c);
                    }
                } catch (NullReferenceException) {
                    //Some cookies make the .NET cookie class barf. MEGH again.
                } catch (IndexOutOfRangeException) {
                    //Another weird exception that comes through from the cookie class.
                }
            }
        }