@@ -195,7 +195,7 @@ public void SetStreamContent(Stream content)
195195 using var activity = _activitySource ? . StartActivity ( nameof ( SetStreamContent ) ) ;
196196 SetRequestType ( content , activity ) ;
197197 Content = content ;
198- Headers . Add ( ContentTypeHeader , BinaryContentType ) ;
198+ Headers . TryAdd ( ContentTypeHeader , BinaryContentType ) ;
199199 }
200200 private static ActivitySource _activitySource = new ( typeof ( RequestInformation ) . Namespace ! ) ;
201201 /// <summary>
@@ -211,7 +211,7 @@ public void SetContentFromParsable<T>(IRequestAdapter requestAdapter, string con
211211 using var writer = GetSerializationWriter ( requestAdapter , contentType , items ) ;
212212 SetRequestType ( items . FirstOrDefault ( static x => x != null ) , activity ) ;
213213 writer . WriteCollectionOfObjectValues ( null , items ) ;
214- Headers . Add ( ContentTypeHeader , contentType ) ;
214+ Headers . TryAdd ( ContentTypeHeader , contentType ) ;
215215 Content = writer . GetSerializedContent ( ) ;
216216 }
217217 /// <summary>
@@ -232,7 +232,7 @@ public void SetContentFromParsable<T>(IRequestAdapter requestAdapter, string con
232232 mpBody . RequestAdapter = requestAdapter ;
233233 }
234234 writer . WriteObjectValue ( null , item ) ;
235- Headers . Add ( ContentTypeHeader , contentType ) ;
235+ Headers . TryAdd ( ContentTypeHeader , contentType ) ;
236236 Content = writer . GetSerializedContent ( ) ;
237237 }
238238 private static void SetRequestType ( object ? result , Activity ? activity )
@@ -261,7 +261,7 @@ public void SetContentFromScalarCollection<T>(IRequestAdapter requestAdapter, st
261261 using var writer = GetSerializationWriter ( requestAdapter , contentType , items ) ;
262262 SetRequestType ( items . FirstOrDefault ( static x => x != null ) , activity ) ;
263263 writer . WriteCollectionOfPrimitiveValues ( null , items ) ;
264- Headers . Add ( ContentTypeHeader , contentType ) ;
264+ Headers . TryAdd ( ContentTypeHeader , contentType ) ;
265265 Content = writer . GetSerializedContent ( ) ;
266266 }
267267 /// <summary>
@@ -323,7 +323,7 @@ public void SetContentFromScalar<T>(IRequestAdapter requestAdapter, string conte
323323 default :
324324 throw new InvalidOperationException ( $ "error serialization data value with unknown type { item ? . GetType ( ) } ") ;
325325 }
326- Headers . Add ( ContentTypeHeader , contentType ) ;
326+ Headers . TryAdd ( ContentTypeHeader , contentType ) ;
327327 Content = writer . GetSerializedContent ( ) ;
328328 }
329329 }
0 commit comments