Exemplo n.º 1
0
        public async Task SetAsync(ExchangeId exchangeId, Exception exception, CancellationToken cancellationToken)
        {
            // write the model
            var exceptionString = exception.ToString();
            var storedModel     = new HttpResponseOrException {
                Response = null, ExceptionString = exceptionString
            };
            var modelKey = GetResponseOrExceptionKey(exchangeId);

            await SetModelAsync(modelKey, storedModel, cancellationToken).ConfigureAwait(false);
        }
Exemplo n.º 2
0
        public async Task SetAsync(ExchangeId exchangeId, HttpResponseMessage response, CancellationToken cancellationToken)
        {
            // map to a simpler model
            var responseModel = await _mapper.ToHttpAsync(response, cancellationToken).ConfigureAwait(false);

            // write the content
            if (responseModel.HasContent)
            {
                var contentKey = GetResponseContentKey(exchangeId);
                response.Content = await SetAndGetContentAsync(contentKey, responseModel.Content, response.Content.Headers, cancellationToken).ConfigureAwait(false);
            }

            // write the model
            var storedModel = new HttpResponseOrException {
                Response = responseModel, ExceptionString = null
            };
            var modelKey = GetResponseOrExceptionKey(exchangeId);

            await SetModelAsync(modelKey, storedModel, cancellationToken).ConfigureAwait(false);
        }