Esempio n. 1
0
        public static void CopyRequestHeaders(IEnumerable<KeyValuePair<string, IEnumerable<string>>> source,
            HttpRequestHeaders destination)
        {
            foreach (var header in source)
            {
                switch (header.Key)
                {
                    case "User-Agent":
                        destination.Add(header.Key, "dev/1.0");
                        break;

                    case "Via":
                        break;

                    default:
                        destination.Add(header.Key, String.Join(",", header.Value));
                        break;
                }
            }
        }
 internal void Populate(HttpRequestHeaders headers)
 {
     if (this.CacheControl != null)
     {
         headers.Add("response-cache-control", this.CacheControl);
     }
     if (this.ContentDisposition != null)
     {
         headers.Add("response-content-disposition", this.ContentDisposition);
     }
     if (this.ContentEncoding != null)
     {
         headers.Add("response-content-encoding", this.ContentEncoding);
     }
     if (this.ContentLanguage != null)
     {
         headers.Add("response-content-language", this.ContentLanguage);
     }
     if (this.ContentType != null)
     {
         headers.Add("response-content-type", this.ContentType);
     }
     if (this.Expires != null)
     {
         headers.Add("response-expires", this.Expires);
     }
 }
 // I would have prefered to return a list of headers instead of relying on a side effect,
 // but I was having problems getting the accept header to work properly. If anyone has any
 // refactoring ideas, I'm listening...
 public void SetHeaders(HttpRequestHeaders headers)
 {
     headers.Add(Constants.AuthorizationHeaderName, this.AuthorizationHeader());
     headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
 }
Esempio n. 4
0
        /// <summary>
        ///     Resets the headers to make any request to the Nexon Api look legit
        /// </summary>
        /// <param name="headers">The <see cref="HttpRequestHeaderCollection" /> that gets modified</param>
        private static void SetHeaders(HttpRequestHeaders headers)
        {
            headers.Clear();

            headers.Accept.ParseAdd("application/json, text/javascript, */*; q=0.01");
            headers.AcceptEncoding.ParseAdd("gzip,deflate");
            headers.AcceptLanguage.ParseAdd("en-GB,en-us;q=0.8,en;q=0.6");
            headers.UserAgent.ParseAdd(GetUserAgent);
            headers.Connection.TryParseAdd("keep-alive");
            headers.Host = new Uri(LoginUrl).Host;
            headers.Add("X-Requested-With", "XMLHttpRequest");
        }
 /// <summary>
 /// Adds the user name and password as http headers elements for the corresponding bulk file upload operation.
 /// </summary>
 /// <param name="requestHeaders">The headers collection to which authentication requests should be added.</param>
 protected internal override void AddAuthenticationHeaders(HttpRequestHeaders requestHeaders)
 {
     requestHeaders.Add("UserName", _username);
     requestHeaders.Add("Password", _password);
 }
Esempio n. 6
0
 private void UpdateHeaders( HttpRequestHeaders headers ) {
     headers.Add( "PddToken", PddToken );
     headers.Authorization = AuthenticationHeaderValue.Parse( $"OAuth {AuthToken.Token}" );
 }
        /// <summary>
        /// Adds the AuthenticationToken header element for the corresponding bulk file upload operation. 
        /// </summary>
        /// <param name="requestHeaders">The headers collection to which authentication requests should be added.</param>
        protected internal override void AddAuthenticationHeaders(HttpRequestHeaders requestHeaders)
        {
            if (OAuthTokens == null)
            {
                throw new InvalidOperationException(ErrorMessages.GetFullOAuthAccessTokenNotRequestedMessage(GetType()));
            }

            requestHeaders.Add("AuthenticationToken", OAuthTokens.AccessToken);
        }
Esempio n. 8
0
        private Task TransferHeaders(IHeaderDictionary sourceHeaders, HttpRequestHeaders destinationHeaders)
        {
            destinationHeaders.Add("Accept", sourceHeaders.ContainsKey("Accept")
                ? sourceHeaders["Accept"].ToString()
                : "image/*");

            destinationHeaders.Add("Accept-Encoding", sourceHeaders.ContainsKey("Accept-Encoding")
                ? sourceHeaders["Accept-Encoding"].ToString()
                : string.Empty);

            destinationHeaders.Add("X-Frame-Options", _defaultHeaders["X-Frame-Options"]);

            destinationHeaders.Add("X-XSS-Protection", _defaultHeaders["X-XSS-Protection"]);

            destinationHeaders.Add("X-Content-Type-Options", _defaultHeaders["X-Content-Type-Options"]);

            //destinationHeaders.Add("Content-Security-Policy", _defaultHeaders["Content-Security-Policy"]);

            return Task.FromResult(0);
        }