public async Task <SynchronizationReport> PushChangesAsync(CancellationToken token) { token.Register(() => { }); //request.Abort() TODO: check this token.ThrowIfCancellationRequested(); if (sourceStream.CanRead == false) { throw new Exception("Stream does not support reading"); } var commands = (IAsyncFilesCommandsImpl)this.destination.Commands; var baseUrl = commands.UrlFor(); var credentials = commands.PrimaryCredentials; var conventions = commands.Conventions; request = commands.RequestFactory.CreateHttpJsonRequest( new CreateHttpJsonRequestParams(this, baseUrl + "/synchronization/MultipartProceed", "POST", credentials, conventions)); // REVIEW: (Oren) There is a mismatch of expectations in the AddHeaders. ETag must always have to be surrounded by quotes. // If AddHeader/s ever put an etag it should check for that. // I was hesitant to do the change though, because I do not understand the complete scope of such a change. request.AddHeaders(sourceMetadata); request.AddHeader("Content-Type", "multipart/form-data; boundary=" + syncingBoundary); request.AddHeader(SyncingMultipartConstants.FileName, fileName); request.AddHeader(SyncingMultipartConstants.SourceServerInfo, serverInfo.AsJson()); try { await request.WriteAsync(PrepareMultipartContent(token)); var response = await request.ReadResponseJsonAsync(); return(new JsonSerializer().Deserialize <SynchronizationReport>(new RavenJTokenReader(response))); } catch (Exception exception) { if (token.IsCancellationRequested) { throw new OperationCanceledException(token); } var webException = exception as ErrorResponseException; if (webException != null) { webException.SimplifyException(); } throw; } }