Beispiel #1
0
        /// <summary>
        /// Adds the necessary headers to the given list of headers. This includes the authorization header,
        /// which uses other headers, so when you need to override this method,
        /// make sure to call <code>base.AddGenericHeaders</code> at the <i>end</i> of your overridden method.
        /// </summary>
        protected IEnumerable <IRequestHeader> AddGenericHeaders(HttpMethod httpMethod, Uri uri, IEnumerable <IRequestHeader> requestHeaders, CallContext context)
        {
            var requestHeaderList = requestHeaders.ToList();

            // add server meta info headers
            requestHeaderList.AddRange(_session.MetaDataProvider.ServerMetaDataHeaders);

            // add date header
            requestHeaderList.Add(new RequestHeader("Date", GetHeaderDateString()));

            // add context specific headers
            if (context != null && context.IdempotenceKey != null)
            {
                requestHeaderList.Add(new RequestHeader("X-GCS-Idempotence-Key", context.IdempotenceKey));
            }

            // add signature
            IAuthenticator authenticator           = _session.Authenticator;
            string         authenticationSignature = authenticator.CreateSimpleAuthenticationSignature(httpMethod, uri, requestHeaderList);

            requestHeaderList.Add(new RequestHeader("Authorization", authenticationSignature));
            return(requestHeaderList);
        }