public override void Remove(string name) { #if NETFX_CORE throw new PlatformNotSupportedException(); #else _actual.Remove(name); #endif }
/// <summary> /// Filter Headers collection and removes headers which aren't in array allowedHeaders /// </summary> /// <param name="allowedHeaders"></param> public void FilterHeaders(string[] allowedHeaders) { foreach (string key in _headers.AllKeys) { //if not in allowed headers, remove it if (Array.IndexOf(allowedHeaders, key) == -1) { _headers.Remove(key); } } }
/// <summary> /// Applies the transform to the request. /// </summary> /// <param name="request"> The web request.</param> /// <param name="response"> The web response.</param> public override void ApplyTransform(WebRequest request, WebResponse response) { base.ApplyTransform (request, response); try { System.Net.WebHeaderCollection headers = new System.Net.WebHeaderCollection(); WebHeader.FillWebHeaderCollection(headers,request.RequestHttpSettings.AdditionalHeaders); foreach ( TransformAction transformAction in _actions ) { // Add Header if ( transformAction is AddTransformAction ) { AddTransformAction add = (AddTransformAction)transformAction; object result = add.Value.GetValue(response); if ( headers[add.Name] == null ) { headers.Add(add.Name, Convert.ToString(result)); } } // Update Header if ( transformAction is UpdateTransformAction ) { UpdateTransformAction update = (UpdateTransformAction)transformAction; object result = update.Value.GetValue(response); SetHeaderValue(request, update.Name, Convert.ToString(result), headers); } // Remove Header if ( transformAction is RemoveTransformAction ) { RemoveTransformAction remove = (RemoveTransformAction)transformAction; if ( headers[remove.Name] != null ) { headers.Remove(remove.Name); } } } // update request request.RequestHttpSettings.AdditionalHeaders = WebHeader.ToArray(headers); } catch ( Exception ex ) { ExceptionManager.Publish(ex); } }