예제 #1
0
		private async Task<SendResult> Send(MaloneRestRequest request, CancellationToken token)
		{
			var result = new SendResult();

			var client = new RestClient(request.BaseUrl)
			{
				FollowRedirects = false
			};

			result.SentAt = DateTimeOffset.UtcNow;
			var response = await client.ExecuteTaskAsync(request, token);
			result.ReceivedAt = DateTimeOffset.UtcNow;
			result.Response = response;
			
			return result;
		}
예제 #2
0
파일: Request.cs 프로젝트: jayxx1234/Malone
        public MaloneRestRequest ToMaloneRestRequest()
        {
            var url          = GetUri();
            var baseUrl      = GetBaseUrl(url);
            var resourcePath = GetResourcePath(url);
            var request      = new MaloneRestRequest(url, baseUrl, resourcePath, Method);

            foreach (var header in Headers.Where(h => h.Name != Header.ContentType))
            {
                request.AddHeader(header.Name, header.Value);
            }

            request.AddParameter(Headers.Single(h => h.Name == Header.ContentType).Value, Body, ParameterType.RequestBody);

            return(request);
        }
예제 #3
0
파일: ApiClient.cs 프로젝트: raydenl/Malone
        private async Task <SendResult> Send(MaloneRestRequest request, CancellationToken token)
        {
            var result = new SendResult();

            var client = new RestClient(request.BaseUrl)
            {
                FollowRedirects = false
            };

            result.SentAt = DateTimeOffset.UtcNow;
            var response = await client.ExecuteTaskAsync(request, token);

            result.ReceivedAt = DateTimeOffset.UtcNow;
            result.Response   = response;

            return(result);
        }
예제 #4
0
파일: Request.cs 프로젝트: jayxx1234/Malone
        public MaloneRestRequest ToMaloneRestRequest()
        {
            var url = GetUri();
            var baseUrl = GetBaseUrl(url);
            var resourcePath = GetResourcePath(url);
            var request = new MaloneRestRequest(url, baseUrl, resourcePath, Method);

            foreach (var header in Headers.Where(h => h.Name != Header.ContentType))
                request.AddHeader(header.Name, header.Value);

            request.AddParameter(Headers.Single(h => h.Name == Header.ContentType).Value, Body, ParameterType.RequestBody);

            return request;
        }