public void AddHeaders(HttpJsonRequest httpJsonRequest, AsyncServerClient serverClient, string currentUrl) { httpJsonRequest.AddHeader(Constants.Cluster.ClusterAwareHeader, "true"); if (serverClient.ClusterBehavior == ClusterBehavior.ReadFromAllWriteToLeader) httpJsonRequest.AddHeader(Constants.Cluster.ClusterReadBehaviorHeader, "All"); if (serverClient.ClusterBehavior == ClusterBehavior.ReadFromAllWriteToLeaderWithFailovers || serverClient.ClusterBehavior == ClusterBehavior.ReadFromLeaderWriteToLeaderWithFailovers) httpJsonRequest.AddHeader(Constants.Cluster.ClusterFailoverBehaviorHeader, "true"); }
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; } }
public void AddHeaders(HttpJsonRequest httpJsonRequest, AsyncServerClient serverClient, string currentUrl, bool withClusterFailoverHeader = false) { httpJsonRequest.AddHeader(Constants.Cluster.ClusterAwareHeader, "true"); if (serverClient.convention.FailoverBehavior == FailoverBehavior.ReadFromAllWriteToLeader) { httpJsonRequest.AddHeader(Constants.Cluster.ClusterReadBehaviorHeader, "All"); } if (withClusterFailoverHeader) { httpJsonRequest.AddHeader(Constants.Cluster.ClusterFailoverBehaviorHeader, "true"); } }
internal static void AddEtagHeader(HttpJsonRequest request, Etag etag) { if (etag != null) { request.AddHeader("If-None-Match", "\"" + etag + "\""); } }
public void AddHeaders(HttpJsonRequest httpJsonRequest, AsyncServerClient serverClient, string currentUrl) { if (serverClient.Url.Equals(currentUrl, StringComparison.OrdinalIgnoreCase)) { return; } if (ReplicationInformer.FailureCounters.GetFailureCount(serverClient.Url) <= 0) { return; // not because of failover, no need to do this. } var lastPrimaryCheck = ReplicationInformer.FailureCounters.GetFailureLastCheck(serverClient.Url); httpJsonRequest.AddHeader(Constants.Headers.RavenClientPrimaryServerUrl, ToRemoteUrl(serverClient.Url)); httpJsonRequest.AddHeader(Constants.Headers.RavenClientPrimaryServerLastCheck, lastPrimaryCheck.ToString("s")); httpJsonRequest.AddReplicationStatusChangeBehavior(serverClient.Url, currentUrl, HandleReplicationStatusChanges); }