示例#1
0
        /// <summary>
        /// Enhance a request with auth token.
        /// </summary>
        /// <param name="context">The data service context for the request.</param>
        /// <param name="request">The request.</param>
        private static void EnhanceRequest(ServerDataServiceSqlAuth context, HttpWebRequest request)
        {
            lock (context.instanceSyncObject)
            {
                foreach (KeyValuePair <string, string> entry in context.supplementalHeaderEntries)
                {
                    request.Headers[entry.Key] = entry.Value;
                }
            }

            // Add the UserAgent string
            request.UserAgent = ApiConstants.UserAgentHeaderValue;

            // Add the access token header
            request.Headers[DataServiceConstants.AccessTokenHeader] = context.accessToken.AccessToken;

            // Add the access token cookie
            request.CookieContainer = new CookieContainer();
            request.CookieContainer.Add(context.accessToken.AccessCookie);

            // Add the session activity Id
            request.Headers[DataServiceConstants.SessionTraceActivityHeader] = context.sessionActivityId.ToString();

            // Add the client tracing Ids
            request.Headers[Constants.ClientSessionIdHeaderName] = context.ClientSessionId;
            request.Headers[Constants.ClientRequestIdHeaderName] = context.ClientRequestId;
        }
        /// <summary>
        /// Enhance a request with auth token.
        /// </summary>
        /// <param name="context">The data service context for the request.</param>
        /// <param name="request">The request.</param>
        private static void EnhanceRequest(ServerDataServiceSqlAuth context, HttpWebRequest request)
        {
            lock (context.instanceSyncObject)
            {
                foreach (KeyValuePair<string, string> entry in context.supplementalHeaderEntries)
                {
                    request.Headers[entry.Key] = entry.Value;
                }
            }

            // Add the UserAgent string
            request.UserAgent = ApiConstants.UserAgentHeaderValue;

            // Add the access token header
            request.Headers[DataServiceConstants.AccessTokenHeader] = context.accessToken.AccessToken;

            // Add the access token cookie
            request.CookieContainer = new CookieContainer();
            request.CookieContainer.Add(context.accessToken.AccessCookie);

            // Add the session activity Id
            request.Headers[DataServiceConstants.SessionTraceActivityHeader] = context.sessionActivityId.ToString();

            // Add the client tracing Ids
            request.Headers[Constants.ClientSessionIdHeaderName] = context.ClientSessionId;
            request.Headers[Constants.ClientRequestIdHeaderName] = context.ClientRequestId;
        }