protected virtual string GenerateRelativeUrl(ReplaceDocumentRequest request)
        {
            var urlParams = new UrlParams();

            urlParams.AddIfNotNullOrWhiteSpace("rev", request.SrcRev);

            return string.Format("/{0}{1}", new UrlSegment(request.SrcId), new QueryString(urlParams));
        }
        public virtual HttpRequest Create(ReplaceDocumentRequest request)
        {
            Ensure.That(request, "request").IsNotNull();

            var httpRequest = new HttpRequest(new HttpMethod("COPY"), GenerateRelativeUrl(request))
                .SetRequestTypeHeader(request.GetType())
                .SetIfMatchHeader(request.SrcRev);

            httpRequest.Headers.Add("Destination", string.Concat(request.TrgId, "?rev=", request.TrgRev));

            return httpRequest;
        }
Exemplo n.º 3
0
        public virtual async Task<DocumentHeaderResponse> ReplaceAsync(ReplaceDocumentRequest request)
        {
            Ensure.That(request, "request").IsNotNull();

            using (var httpRequest = CreateHttpRequest(request))
            {
                using (var res = await SendAsync(httpRequest).ForAwait())
                {
                    return ProcessDocumentHeaderResponse(res);
                }
            }
        }
Exemplo n.º 4
0
 protected virtual HttpRequest CreateHttpRequest(ReplaceDocumentRequest request)
 {
     return ReplaceDocumentHttpRequestFactory.Create(request);
 }