@@ -15,6 +15,7 @@ public class SyncClient
15
15
private readonly string synchronizationId ;
16
16
private readonly SyncEngine syncEngine ;
17
17
private readonly string serverUrl ;
18
+ private readonly Dictionary < string , string > httpHeaders ;
18
19
19
20
public enum SynchronizationMethodEnum
20
21
{
@@ -23,10 +24,16 @@ public enum SynchronizationMethodEnum
23
24
}
24
25
25
26
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 )
26
32
{
27
33
this . synchronizationId = synchronizationId ?? throw new NullReferenceException ( nameof ( synchronizationId ) ) ;
28
34
this . syncEngine = syncEngine ?? throw new NullReferenceException ( nameof ( syncEngine ) ) ;
29
35
this . serverUrl = serverUrl ?? throw new NullReferenceException ( nameof ( serverUrl ) ) ;
36
+ this . httpHeaders = httpHeaders ;
30
37
}
31
38
32
39
public async Task < SyncResult > SynchronizeAsync ( SynchronizationMethodEnum synchronizationMethod = SynchronizationMethodEnum . PushThenPull , Dictionary < string , object > customInfo = null )
@@ -345,6 +352,15 @@ private async Task SynchronizeGlobalTimeStamp(SynchronizationMethodEnum synchron
345
352
346
353
using ( var httpClient = new HttpClient ( ) )
347
354
{
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
+
348
364
using ( var multipartFormDataContent = new MultipartFormDataContent ( ) )
349
365
{
350
366
ByteArrayContent byteArrayContent = new ByteArrayContent ( compressed ) ;
0 commit comments