@@ -15,6 +15,7 @@ public class SyncClient
1515 private readonly string synchronizationId ;
1616 private readonly SyncEngine syncEngine ;
1717 private readonly string serverUrl ;
18+ private readonly Dictionary < string , string > httpHeaders ;
1819
1920 public enum SynchronizationMethodEnum
2021 {
@@ -23,10 +24,16 @@ public enum SynchronizationMethodEnum
2324 }
2425
2526 public SyncClient ( string synchronizationId , SyncEngine syncEngine , string serverUrl )
27+ : this ( synchronizationId , syncEngine , serverUrl , null )
28+ {
29+ }
30+
31+ public SyncClient ( string synchronizationId , SyncEngine syncEngine , string serverUrl , Dictionary < string , string > httpHeaders )
2632 {
2733 this . synchronizationId = synchronizationId ?? throw new NullReferenceException ( nameof ( synchronizationId ) ) ;
2834 this . syncEngine = syncEngine ?? throw new NullReferenceException ( nameof ( syncEngine ) ) ;
2935 this . serverUrl = serverUrl ?? throw new NullReferenceException ( nameof ( serverUrl ) ) ;
36+ this . httpHeaders = httpHeaders ;
3037 }
3138
3239 public async Task < SyncResult > SynchronizeAsync ( SynchronizationMethodEnum synchronizationMethod = SynchronizationMethodEnum . PushThenPull , Dictionary < string , object > customInfo = null )
@@ -345,6 +352,15 @@ private async Task SynchronizeGlobalTimeStamp(SynchronizationMethodEnum synchron
345352
346353 using ( var httpClient = new HttpClient ( ) )
347354 {
355+ if ( httpHeaders != null )
356+ {
357+ httpHeaders . ToList ( ) . ForEach ( kvp =>
358+ {
359+ if ( httpClient . DefaultRequestHeaders . Contains ( kvp . Key ) ) httpClient . DefaultRequestHeaders . Remove ( kvp . Key ) ;
360+ httpClient . DefaultRequestHeaders . Add ( kvp . Key , kvp . Value ) ;
361+ } ) ;
362+ }
363+
348364 using ( var multipartFormDataContent = new MultipartFormDataContent ( ) )
349365 {
350366 ByteArrayContent byteArrayContent = new ByteArrayContent ( compressed ) ;
0 commit comments