Ejemplo n.º 1
0
        internal static void RewriteHeadersWithParameters(HttpRequest request, IEnumerable<PlaceholderValue> headerParameters)
        {
            foreach (var param in headerParameters)
            {
                string headerName = param.PlaceholderKey;
                if (param.PlaceholderKey.EndsWith(":"))
                    headerName = param.PlaceholderKey.Substring(0, param.PlaceholderKey.Length - 1);

                if (param.Value == null)
                    request.Headers.Remove(headerName);
                else 
                    request.Headers[headerName] = param.Value;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Breaks down the key/value string and adds to the request header
 /// </summary>
 /// <param name="headerKeyValueString"></param>
 /// <returns></returns>
 internal static void AddAdditionalHeadersToRequest(IServiceAccount account, HttpRequest request)
 {
     // parse the passed in addtional headers and add to request..format for headers should be <HeaderName>:<HeaderValue>
     if (account.AdditionalHeaders != null && account.AdditionalHeaders.Length > 0)
     {
         foreach (string nameValueHeader in account.AdditionalHeaders)
         {
             string[] split = nameValueHeader.Split(new Char[] { ':' }, 2);
             request.Headers.Add(split[0], split[1]);
         }
     }
 }    
Ejemplo n.º 3
0
 internal static void AddAccessTokenToRequest(AuthenicationCredentials credentials, HttpRequest request)
 {
     credentials.AuthenticateRequest(request);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Add information about the test that generated this call to the request headers.
 /// </summary>
 /// <param name="scenario"></param>
 /// <param name="request"></param>
 internal static void AddTestHeaderToRequest(ScenarioDefinition scenario, HttpRequest request)
 {
     var headerValue = string.Format(
         "method-name: {0}; scenario-name: {1}",
         scenario.MethodName,
         scenario.Description);
     request.Headers.Add("ApiDocsTestInfo", headerValue);
 }