Permalink
Browse files

Exposed intercepted request and request factory

  • Loading branch information...
1 parent 92f4567 commit 9d2345250c47843073fdcd12c1545b4eb94be38c @bbaia bbaia committed Feb 7, 2012
@@ -34,12 +34,20 @@ namespace Spring.Http.Client.Interceptor
/// <author>Bruno Baia</author>
public class InterceptingClientHttpRequest : IClientHttpRequest
{
- private IClientHttpRequest delegateRequest;
+ private IClientHttpRequest targetRequest;
private IEnumerable<IClientHttpRequestInterceptor> interceptors;
private Action<Stream> body;
/// <summary>
+ /// Gets the intercepted request.
+ /// </summary>
+ public IClientHttpRequest TargetRequest
+ {
+ get { return this.targetRequest; }
+ }
+
+ /// <summary>
/// Creates a new instance of the <see cref="InterceptingClientHttpRequest"/> with the given parameters.
/// </summary>
/// <param name="request">The request to wrap.</param>
@@ -50,7 +58,7 @@ public class InterceptingClientHttpRequest : IClientHttpRequest
{
ArgumentUtils.AssertNotNull(request, "request");
- this.delegateRequest = request;
+ this.targetRequest = request;
this.interceptors = interceptors != null ? interceptors : new IClientHttpRequestInterceptor[0];
}
@@ -61,23 +69,23 @@ public class InterceptingClientHttpRequest : IClientHttpRequest
/// </summary>
public HttpMethod Method
{
- get { return this.delegateRequest.Method; }
+ get { return this.targetRequest.Method; }
}
/// <summary>
/// Gets the URI of the request.
/// </summary>
public Uri Uri
{
- get { return this.delegateRequest.Uri; }
+ get { return this.targetRequest.Uri; }
}
/// <summary>
/// Gets the message headers.
/// </summary>
public HttpHeaders Headers
{
- get { return this.delegateRequest.Headers; }
+ get { return this.targetRequest.Headers; }
}
/// <summary>
@@ -89,7 +97,7 @@ public Action<Stream> Body
set
{
this.body = value;
- this.delegateRequest.Body = value;
+ this.targetRequest.Body = value;
}
}
@@ -100,7 +108,7 @@ public Action<Stream> Body
/// <returns>The response result of the execution</returns>
public IClientHttpResponse Execute()
{
- RequestSyncExecution requestSyncExecution = new RequestSyncExecution(this.delegateRequest, this.body, this.interceptors);
+ RequestSyncExecution requestSyncExecution = new RequestSyncExecution(this.targetRequest, this.body, this.interceptors);
return requestSyncExecution.Execute();
}
#endif
@@ -118,7 +126,7 @@ public IClientHttpResponse Execute()
/// </param>
public void ExecuteAsync(object state, Action<ClientHttpRequestCompletedEventArgs> executeCompleted)
{
- RequestAsyncExecution requestAsyncExecution = new RequestAsyncExecution(this.delegateRequest, this.body, this.interceptors, state, executeCompleted);
+ RequestAsyncExecution requestAsyncExecution = new RequestAsyncExecution(this.targetRequest, this.body, this.interceptors, state, executeCompleted);
requestAsyncExecution.ExecuteAsync();
}
@@ -127,7 +135,7 @@ public void ExecuteAsync(object state, Action<ClientHttpRequestCompletedEventArg
/// </summary>
public void CancelAsync()
{
- this.delegateRequest.CancelAsync();
+ this.targetRequest.CancelAsync();
}
#endif
@@ -33,10 +33,18 @@ namespace Spring.Http.Client.Interceptor
/// <author>Bruno Baia</author>
public class InterceptingClientHttpRequestFactory : IClientHttpRequestFactory
{
- private IClientHttpRequestFactory requestFactory;
+ private IClientHttpRequestFactory targetRequestFactory;
private IEnumerable<IClientHttpRequestInterceptor> interceptors;
/// <summary>
+ /// Gets the intercepted request factory.
+ /// </summary>
+ public IClientHttpRequestFactory TargetRequestFactory
+ {
+ get { return this.targetRequestFactory; }
+ }
+
+ /// <summary>
/// Creates a new instance of the <see cref="InterceptingClientHttpRequestFactory"/> with the given parameters.
/// </summary>
/// <param name="requestFactory">The request factory to wrap.</param>
@@ -47,7 +55,7 @@ public class InterceptingClientHttpRequestFactory : IClientHttpRequestFactory
{
ArgumentUtils.AssertNotNull(requestFactory, "requestFactory");
- this.requestFactory = requestFactory;
+ this.targetRequestFactory = requestFactory;
this.interceptors = interceptors != null ? interceptors : new IClientHttpRequestInterceptor[0];
}
@@ -61,7 +69,7 @@ public class InterceptingClientHttpRequestFactory : IClientHttpRequestFactory
/// <returns>The created request</returns>
public IClientHttpRequest CreateRequest(Uri uri, HttpMethod method)
{
- RequestCreation requestCreation = new RequestCreation(uri, method, this.requestFactory, this.interceptors);
+ RequestCreation requestCreation = new RequestCreation(uri, method, this.targetRequestFactory, this.interceptors);
IClientHttpRequest request = requestCreation.Create();
return new InterceptingClientHttpRequest(request, this.interceptors);
}

0 comments on commit 9d23452

Please sign in to comment.