protected virtual HttpRequestMessage CreateRequest(GetAttachmentCommand cmd) { var req = new HttpRequest(HttpMethod.Get, GenerateRequestUrl(cmd.DocId, cmd.DocRev, cmd.Name)); req.SetIfMatch(cmd.DocRev); return req; }
public virtual HttpRequest Create(GetAttachmentRequest request) { Ensure.That(request, "request").IsNotNull(); var httpRequest = new HttpRequest(HttpMethod.Get, GenerateRelativeUrl(request)) .SetRequestTypeHeader(request.GetType()) .SetIfMatchHeader(request.DocRev); return httpRequest; }
public virtual async Task<HttpResponseMessage> SendAsync(HttpRequest httpRequest, CancellationToken cancellationToken) { ThrowIfDisposed(); OnBeforeSend(httpRequest); using (var message = CreateHttpRequestMessage(httpRequest)) { return await HttpClient.SendAsync(message, cancellationToken).ForAwait(); } }
public virtual HttpRequest Create(CopyDocumentRequest 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", request.NewId); return httpRequest; }
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; }
public virtual HttpRequest Create(QueryShowRequest request) { Ensure.That(request, "request").IsNotNull(); var httpRequest = new HttpRequest(HttpMethod.Get, GenerateRelativeUrl(request)); httpRequest.SetRequestTypeHeader(request.GetType()); if (request.HasAccepts) httpRequest.SetAcceptHeader(request.Accepts); else httpRequest.SetAcceptHeader(HttpContentTypes.Json, HttpContentTypes.Html); return httpRequest; }
protected virtual HttpRequestMessage CreateRequest(ReplaceDocumentCommand cmd) { var req = new HttpRequest(new HttpMethod("COPY"), GenerateRequestUrl(cmd)); req.Headers.Add("Destination", string.Concat(cmd.TrgId, "?rev=", cmd.TrgRev)); return req; }
protected virtual HttpRequestMessage CreateRequest(BulkCommand cmd) { var req = new HttpRequest(HttpMethod.Post, GenerateRequestUrl(cmd)); req.SetContent(cmd.ToJson()); return req; }
protected virtual HttpRequestMessage CreateRequest(CopyDocumentCommand cmd) { var req = new HttpRequest(new HttpMethod("COPY"), GenerateRequestUrl(cmd)); req.Headers.Add("Destination", cmd.NewId); return req; }
public virtual async Task<HttpResponseMessage> SendAsync(HttpRequest httpRequest, HttpCompletionOption completionOption, CancellationToken cancellationToken) { return await HttpClient.SendAsync(OnBeforeSend(httpRequest), completionOption, cancellationToken).ForAwait(); }
protected virtual HttpRequest OnBeforeSend(HttpRequest httpRequest) { return httpRequest.RemoveRequestType(); }
public Task<HttpResponseMessage> SendAsync(HttpRequest httpRequest) { return null; }
public virtual async Task<HttpResponseMessage> SendAsync(HttpRequest httpRequest) { return await HttpClient.SendAsync(OnBeforeSend(httpRequest)).ForAwait(); }
protected virtual HttpRequestMessage CreateRequest(DocumentExistsCommand cmd) { var req = new HttpRequest(HttpMethod.Head, GenerateRequestUrl(cmd.Id, cmd.Rev)); req.SetIfMatch(cmd.Rev); return req; }
protected virtual HttpRequestMessage CreateRequest(PutDocumentCommand cmd) { var req = new HttpRequest(HttpMethod.Put, GenerateRequestUrl(cmd.Id, cmd.Rev)); req.SetIfMatch(cmd.Rev); req.SetContent(cmd.Content); return req; }
protected virtual string GenerateRequestUri(HttpRequest httpRequest) { return string.Format("{0}/{1}", Address.ToString().TrimEnd('/'), httpRequest.RelativeUrl.TrimStart('/')); }
protected virtual void OnBeforeSend(HttpRequest httpRequest) { }
protected virtual Task<HttpResponseMessage> SendAsync(HttpRequest httpRequest) { return Connection.SendAsync(httpRequest); }
public Task<HttpResponseMessage> SendAsync(HttpRequest httpRequest, HttpCompletionOption completionOption, CancellationToken cancellationToken) { return null; }
public Task<HttpResponseMessage> SendAsync(HttpRequest httpRequest, HttpCompletionOption completionOption) { return null; }
protected virtual HttpRequestMessage CreateRequest(HttpMethod method, JsonDocumentCommand cmd) { var req = new HttpRequest(method, GenerateRequestUrl(cmd)); if (!string.IsNullOrWhiteSpace(cmd.Rev)) req.SetIfMatch(cmd.Rev); req.SetContent(cmd.Content); return req; }
protected virtual HttpRequestMessage CreateRequest(PostDocumentCommand cmd) { var req = new HttpRequest(HttpMethod.Post, GenerateRequestUrl()); req.SetContent(cmd.Content); return req; }
protected virtual HttpRequestMessage CreateHttpRequestMessage(HttpRequest httpRequest) { httpRequest.RemoveRequestTypeHeader(); var message = new HttpRequestMessage(httpRequest.Method, GenerateRequestUri(httpRequest)) { Content = httpRequest.Content, }; foreach (var kv in httpRequest.Headers) message.Headers.TryAddWithoutValidation(kv.Key, kv.Value); return message; }
protected virtual Task<HttpResponseMessage> SendAsync(HttpRequest httpRequest, HttpCompletionOption completionOption, CancellationToken cancellationToken) { return Connection.SendAsync(httpRequest, completionOption, cancellationToken); }