From 2d9b773f293f8e5992a33b48b25bcff41f306a44 Mon Sep 17 00:00:00 2001 From: bbaia Date: Thu, 6 Jan 2011 18:13:50 +0000 Subject: [PATCH] REST client API: Code comments (SPRNET-1345) --- src/Spring/Spring.Http/AssemblyInfo.cs | 2 +- .../Specialized/NameValueCollection.cs | 69 +- .../Http/Client/ExecuteCompletedEventArgs.cs | 24 +- .../Http/Client/IClientHttpRequest.cs | 13 + .../Http/Client/WebClientHttpRequest.cs | 50 +- .../Client/WebClientHttpRequestFactory.cs | 25 +- .../Http/Client/WebClientHttpResponse.cs | 79 +- .../Http/Rest/IRestAsyncOperations.cs | 343 +++++---- .../Spring.Http/Http/Rest/IRestOperations.cs | 108 ++- .../Http/Rest/MethodCompletedEventArgs.cs | 26 +- .../Spring.Http/Http/Rest/RestTemplate.cs | 672 ++++++++++++++++-- src/Spring/Spring.Http/Util/AssertUtils.cs | 2 + src/Spring/Spring.Http/Util/StringUtils.cs | 2 + .../FormHttpMessageConverterTests.cs | 2 +- 14 files changed, 1096 insertions(+), 321 deletions(-) diff --git a/src/Spring/Spring.Http/AssemblyInfo.cs b/src/Spring/Spring.Http/AssemblyInfo.cs index 43bd989e..9fa04a7a 100644 --- a/src/Spring/Spring.Http/AssemblyInfo.cs +++ b/src/Spring/Spring.Http/AssemblyInfo.cs @@ -2,4 +2,4 @@ using System; using System.Reflection; [assembly: AssemblyTitle("Spring.Http")] -[assembly: AssemblyDescription("Interfaces and classes that provide REST client API in Spring.Net")] \ No newline at end of file +[assembly: AssemblyDescription("Interfaces and classes that provide REST client API in Spring.NET")] \ No newline at end of file diff --git a/src/Spring/Spring.Http/Collections/Specialized/NameValueCollection.cs b/src/Spring/Spring.Http/Collections/Specialized/NameValueCollection.cs index 17fa51aa..b28ecaa0 100644 --- a/src/Spring/Spring.Http/Collections/Specialized/NameValueCollection.cs +++ b/src/Spring/Spring.Http/Collections/Specialized/NameValueCollection.cs @@ -25,30 +25,57 @@ using System.Collections.Generic; namespace Spring.Collections.Specialized { + /// + /// Represents a collection of associated string keys and multiple string values. + /// + /// + /// Silverlight's implementation, based on a dictionary, of the .NET Framework NameValueCollection class. + /// + /// Bruno Baia public class NameValueCollection : IEnumerable { private Dictionary> innerCollection; + /// + /// Creates a new instance of the class. + /// public NameValueCollection() { innerCollection = new Dictionary>(); } + /// + /// Creates a new instance of the class + /// with the specified initial capacity. + /// public NameValueCollection(int capacity) { innerCollection = new Dictionary>(capacity); } + /// + /// Creates a new instance of the class + /// with the specified comparer. + /// public NameValueCollection(IEqualityComparer comparer) { innerCollection = new Dictionary>(comparer); } + /// + /// Creates a new instance of the class + /// with the specified initial capacity and comparer. + /// public NameValueCollection(int capacity, IEqualityComparer comparer) { innerCollection = new Dictionary>(capacity, comparer); } + /// + /// Adds the given single value to the current list of values for the given key. + /// + /// The key to use. + /// The value to add. public virtual void Add(string name, string value) { List list; @@ -60,6 +87,11 @@ namespace Spring.Collections.Specialized this.innerCollection[name] = list; } + /// + /// Returns values for the given key as a comma-delimited string. + /// + /// The key that contains the values to get. + /// A comma-delimited string, if found; otherwise . public virtual string Get(string name) { string str = null; @@ -85,6 +117,11 @@ namespace Spring.Collections.Specialized return str; } + /// + /// Returns values for the given key as a string array. + /// + /// The key that contains the values to get. + /// A string array, if found; otherwise, . public virtual string[] GetValues(string name) { List list; @@ -95,18 +132,34 @@ namespace Spring.Collections.Specialized return null; } - public virtual void Set(string key, string value) + /// + /// Sets the given single value under the given key. + /// + /// The key to use. + /// The value to set. + public virtual void Set(string name, string value) { List list = new List(); list.Add(value); - this.innerCollection[key] = list; + this.innerCollection[name] = list; } - public virtual bool Remove(string key) + /// + /// Removes the given key from the collection. + /// + /// The key to remove. + /// + /// if the key have been found and removed from the collection; + /// otherwise, . + /// + public virtual bool Remove(string name) { - return this.innerCollection.Remove(key); + return this.innerCollection.Remove(name); } + /// + /// Gets all the keys in the collection. + /// public virtual string[] AllKeys { get @@ -118,6 +171,9 @@ namespace Spring.Collections.Specialized } } + /// + /// Gets the number of keys contained in the collection. + /// public virtual int Count { get @@ -126,6 +182,11 @@ namespace Spring.Collections.Specialized } } + /// + /// Gets values as a comma-delimited string or sets a single value for the given key. + /// + /// The key to use. + /// A comma-delimited string, if found; otherwise . public virtual string this[string name] { get diff --git a/src/Spring/Spring.Http/Http/Client/ExecuteCompletedEventArgs.cs b/src/Spring/Spring.Http/Http/Client/ExecuteCompletedEventArgs.cs index a5b166d0..0ac2f889 100644 --- a/src/Spring/Spring.Http/Http/Client/ExecuteCompletedEventArgs.cs +++ b/src/Spring/Spring.Http/Http/Client/ExecuteCompletedEventArgs.cs @@ -23,24 +23,40 @@ using System.ComponentModel; namespace Spring.Http.Client { + // TODO: Rename this to HttpRequestCompletedEventArgs or something ? + + /// + /// Provides data when an asynchronous HTTP request execution completes. + /// + /// public class ExecuteCompletedEventArgs : AsyncCompletedEventArgs { private IClientHttpResponse response; + /// + /// Gets the response result of the execution. + /// + /// If the execution was canceled. + /// If the execution failed. public IClientHttpResponse Response { get { - // Raise an exception if the operation failed or - // was canceled. + // Raise an exception if the operation failed or was canceled. base.RaiseExceptionIfNecessary(); - // If the operation was successful, return the - // property value. + // If the operation was successful, return the value. return response; } } + /// + /// Creates a new instance of . + /// + /// The response of the execution. + /// Any error that occurred during the asynchronous execution. + /// A value indicating whether the asynchronous execution was canceled. + /// The optional user-supplied state object. public ExecuteCompletedEventArgs(IClientHttpResponse response, Exception exception, bool cancelled, object userState) : base(exception, cancelled, userState) { diff --git a/src/Spring/Spring.Http/Http/Client/IClientHttpRequest.cs b/src/Spring/Spring.Http/Http/Client/IClientHttpRequest.cs index b675a20a..5e27193b 100644 --- a/src/Spring/Spring.Http/Http/Client/IClientHttpRequest.cs +++ b/src/Spring/Spring.Http/Http/Client/IClientHttpRequest.cs @@ -59,8 +59,21 @@ namespace Spring.Http.Client IClientHttpResponse Execute(); #endif + /// + /// Execute this request asynchronously. + /// + /// + /// An optional user-defined object that is passed to the method invoked + /// when the asynchronous operation completes. + /// + /// + /// The to perform when the asynchronous execution completes. + /// void ExecuteAsync(object state, Action executeCompleted); + /// + /// Cancels a pending asynchronous operation. + /// void CancelAsync(); } } diff --git a/src/Spring/Spring.Http/Http/Client/WebClientHttpRequest.cs b/src/Spring/Spring.Http/Http/Client/WebClientHttpRequest.cs index aa1ed763..8f409d58 100644 --- a/src/Spring/Spring.Http/Http/Client/WebClientHttpRequest.cs +++ b/src/Spring/Spring.Http/Http/Client/WebClientHttpRequest.cs @@ -45,7 +45,7 @@ namespace Spring.Http.Client private bool isCancelled; /// - /// Gets the instance used. + /// Gets the instance used by the request. /// public HttpWebRequest HttpWebRequest { @@ -111,6 +111,7 @@ namespace Spring.Http.Client /// Execute this request, resulting in a that can be read. /// /// The response result of the execution + /// If the request is already executed or is currently executing. public IClientHttpResponse Execute() { this.EnsureNotExecuted(); @@ -118,7 +119,7 @@ namespace Spring.Http.Client try { // Prepare - this.PrepareRequest(); + this.PrepareForExecution(); // Write if (this.body != null) @@ -133,7 +134,7 @@ namespace Spring.Http.Client HttpWebResponse httpWebResponse = this.httpWebRequest.GetResponse() as HttpWebResponse; if (this.httpWebRequest.HaveResponse && httpWebResponse != null) { - return new WebClientHttpResponse(httpWebResponse); + return this.CreateClientHttpResponse(httpWebResponse); } } catch (WebException ex) @@ -144,7 +145,7 @@ namespace Spring.Http.Client if (httpWebResponse != null) { this.isExecuted = true; - return new WebClientHttpResponse(httpWebResponse); + return this.CreateClientHttpResponse(httpWebResponse); } throw; } @@ -153,6 +154,17 @@ namespace Spring.Http.Client } #endif + /// + /// Execute this request asynchronously. + /// + /// + /// An optional user-defined object that is passed to the method invoked + /// when the asynchronous operation completes. + /// + /// + /// The to perform when the asynchronous execution completes. + /// + /// If the request is already executed or is currently executing. public void ExecuteAsync(object state, Action executeCompleted) { this.EnsureNotExecuted(); @@ -163,7 +175,7 @@ namespace Spring.Http.Client try { // Prepare - this.PrepareRequest(); + this.PrepareForExecution(); // Post request if (this.body != null) @@ -190,6 +202,9 @@ namespace Spring.Http.Client } } + /// + /// Cancels a pending asynchronous operation. + /// public void CancelAsync() { this.isCancelled = true; @@ -249,7 +264,7 @@ namespace Spring.Http.Client HttpWebResponse httpWebResponse = this.httpWebRequest.EndGetResponse(result) as HttpWebResponse; if (this.httpWebRequest.HaveResponse == true && httpWebResponse != null) { - response = new WebClientHttpResponse(httpWebResponse); + response = this.CreateClientHttpResponse(httpWebResponse); } } catch (Exception ex) @@ -267,7 +282,7 @@ namespace Spring.Http.Client if (httpWebResponse != null) { exception = null; - response = new WebClientHttpResponse(httpWebResponse); + response = this.CreateClientHttpResponse(httpWebResponse); } } } @@ -326,6 +341,10 @@ namespace Spring.Http.Client #endregion + /// + /// Ensures that the request can be executed. + /// + /// If the request is already executed or is currently executing. protected void EnsureNotExecuted() { if (this.isExecuted) @@ -334,13 +353,26 @@ namespace Spring.Http.Client } } + /// + /// Creates and returns an implementation associated + /// with the request. + /// + /// The instance to use. + /// + /// An implementation associated with the request. + /// + protected virtual IClientHttpResponse CreateClientHttpResponse(HttpWebResponse response) + { + return new WebClientHttpResponse(response); + } + /// /// Prepare the request for execution. /// /// - /// Default implementation copies headers to the request. Can be overridden in subclasses. + /// Default implementation copies headers to the .NET request. Can be overridden in subclasses. /// - protected virtual void PrepareRequest() + protected virtual void PrepareForExecution() { // Copy headers foreach (string header in this.headers) diff --git a/src/Spring/Spring.Http/Http/Client/WebClientHttpRequestFactory.cs b/src/Spring/Spring.Http/Http/Client/WebClientHttpRequestFactory.cs index 000a4c76..ae302094 100644 --- a/src/Spring/Spring.Http/Http/Client/WebClientHttpRequestFactory.cs +++ b/src/Spring/Spring.Http/Http/Client/WebClientHttpRequestFactory.cs @@ -102,6 +102,13 @@ namespace Spring.Http.Client #if SILVERLIGHT && !WINDOWS_PHONE private WebRequestCreatorType _webRequestCreator; + /// + /// Gets or sets a value that indicates how HTTP requests and responses will be handled. + /// + /// + /// By default, this factory will use the default Silverlight behavior for HTTP methods GET and POST, + /// and force the client HTTP stack for other HTTP methods. + /// public WebRequestCreatorType WebRequestCreator { get { return this._webRequestCreator; } @@ -127,7 +134,7 @@ namespace Spring.Http.Client public WebClientHttpRequestFactory() { #if SILVERLIGHT && !WINDOWS_PHONE - this._webRequestCreator = WebRequestCreatorType.Default; + this._webRequestCreator = WebRequestCreatorType.Unknown; #endif } @@ -150,7 +157,7 @@ namespace Spring.Http.Client case WebRequestCreatorType.BrowserHttp: this.httpWebRequest = (HttpWebRequest)System.Net.Browser.WebRequestCreator.BrowserHttp.Create(uri); break; - case WebRequestCreatorType.Default: + case WebRequestCreatorType.Unknown: if (method == HttpMethod.GET || method == HttpMethod.POST) { this.httpWebRequest = WebRequest.Create(uri) as HttpWebRequest; @@ -203,10 +210,22 @@ namespace Spring.Http.Client } #if SILVERLIGHT && !WINDOWS_PHONE + /// + /// Defines identifiers for supported Silverlight HTTP handling stacks. + /// public enum WebRequestCreatorType { - Default, + /// + /// Specifies an unknown HTTP handling stack. + /// + Unknown, + /// + /// Specifies browser HTTP handling stack. + /// BrowserHttp, + /// + /// Specifies client HTTP handling stack. + /// ClientHttp } #endif diff --git a/src/Spring/Spring.Http/Http/Client/WebClientHttpResponse.cs b/src/Spring/Spring.Http/Http/Client/WebClientHttpResponse.cs index 60e16dfc..3766feb5 100644 --- a/src/Spring/Spring.Http/Http/Client/WebClientHttpResponse.cs +++ b/src/Spring/Spring.Http/Http/Client/WebClientHttpResponse.cs @@ -37,7 +37,7 @@ namespace Spring.Http.Client private HttpWebResponse httpWebResponse; /// - /// Gets the instance used. + /// Gets the instance used by the response. /// public HttpWebResponse HttpWebResponse { @@ -56,39 +56,7 @@ namespace Spring.Http.Client this.httpWebResponse = response; this.headers = new HttpHeaders(); -#if NET_2_0 || WINDOWS_PHONE - foreach (string header in this.httpWebResponse.Headers) - { - this.headers[header] = this.httpWebResponse.Headers[header]; - } -#endif -#if SILVERLIGHT_3 - try - { - foreach (string header in this.httpWebResponse.Headers) - { - this.headers[header] = this.httpWebResponse.Headers[header]; - } - } - catch(NotImplementedException) - { - this.headers.ContentLength = this.httpWebResponse.ContentLength; - this.headers["Content-Type"] = this.httpWebResponse.ContentType; - } -#elif SILVERLIGHT - if (this.httpWebResponse.SupportsHeaders) - { - foreach (string header in this.httpWebResponse.Headers) - { - this.headers[header] = this.httpWebResponse.Headers[header]; - } - } - else - { - this.headers.ContentLength = this.httpWebResponse.ContentLength; - this.headers["Content-Type"] = this.httpWebResponse.ContentType; - } -#endif + this.Initialize(); } #region IClientHttpResponse Membres @@ -148,5 +116,48 @@ namespace Spring.Http.Client } #endregion + + /// + /// Initialize the response. + /// + /// + /// Default implementation copies headers from the .NET response. Can be overridden in subclasses. + /// + protected virtual void Initialize() + { +#if NET_2_0 || WINDOWS_PHONE + foreach (string header in this.httpWebResponse.Headers) + { + this.headers[header] = this.httpWebResponse.Headers[header]; + } +#endif +#if SILVERLIGHT_3 + try + { + foreach (string header in this.httpWebResponse.Headers) + { + this.headers[header] = this.httpWebResponse.Headers[header]; + } + } + catch(NotImplementedException) + { + this.headers.ContentLength = this.httpWebResponse.ContentLength; + this.headers["Content-Type"] = this.httpWebResponse.ContentType; + } +#elif SILVERLIGHT + if (this.httpWebResponse.SupportsHeaders) + { + foreach (string header in this.httpWebResponse.Headers) + { + this.headers[header] = this.httpWebResponse.Headers[header]; + } + } + else + { + this.headers.ContentLength = this.httpWebResponse.ContentLength; + this.headers["Content-Type"] = this.httpWebResponse.ContentType; + } +#endif + } } } diff --git a/src/Spring/Spring.Http/Http/Rest/IRestAsyncOperations.cs b/src/Spring/Spring.Http/Http/Rest/IRestAsyncOperations.cs index dcf3b8c7..d23e4223 100644 --- a/src/Spring/Spring.Http/Http/Rest/IRestAsyncOperations.cs +++ b/src/Spring/Spring.Http/Http/Rest/IRestAsyncOperations.cs @@ -25,23 +25,23 @@ using System.Collections.Generic; namespace Spring.Http.Rest { /// - /// Interface specifying a basic set of RESTful operations. + /// Interface specifying a basic set of RESTful asynchrone operations. /// /// /// Not often used directly, but a useful option to enhance testability, /// as it can easily be mocked or stubbed. /// /// + /// Bruno Baia (.NET) /// Arjen Poutsma /// Juergen Hoeller - /// Bruno Baia (.NET) public interface IRestAsyncOperations { #region GET /// - /// Retrieve a representation by doing a GET on the specified URL. - /// The response (if any) is converted and returned. + /// Asynchronously retrieve a representation by doing a GET on the specified URL. + /// The response (if any) is converted. /// /// /// URI Template variables are expanded using the given URI variables, if any. @@ -49,12 +49,14 @@ namespace Spring.Http.Rest /// The type of the response value. /// The URL. /// The variables to expand the template. - /// The converted object + /// + /// The Action<T> to perform when the asynchronous GET method completes. + /// void GetForObjectAsync(string url, object[] uriVariables, Action> getCompleted) where T : class; /// - /// Retrieve a representation by doing a GET on the specified URL. - /// The response (if any) is converted and returned. + /// Asynchronously retrieve a representation by doing a GET on the specified URL. + /// The response (if any) is converted. /// /// /// URI Template variables are expanded using the given dictionary. @@ -62,20 +64,24 @@ namespace Spring.Http.Rest /// The type of the response value. /// The URL. /// The dictionary containing variables for the URI template. - /// The converted object + /// + /// The Action<T> to perform when the asynchronous GET method completes. + /// void GetForObjectAsync(string url, IDictionary uriVariables, Action> getCompleted) where T : class; /// - /// Retrieve a representation by doing a GET on the specified URL. - /// The response (if any) is converted and returned. + /// Asynchronously retrieve a representation by doing a GET on the specified URL. + /// The response (if any) is converted. /// /// The type of the response value. /// The URL. - /// The converted object + /// + /// The Action<T> to perform when the asynchronous GET method completes. + /// void GetForObjectAsync(Uri url, Action> getCompleted) where T : class; /// - /// Retrieve an entity by doing a GET on the specified URL. + /// Asynchronously retrieve an entity by doing a GET on the specified URL. /// The response is converted and stored in an . /// /// @@ -84,11 +90,13 @@ namespace Spring.Http.Rest /// The type of the response value. /// The URL. /// The variables to expand the template. - /// The HTTP response message. + /// + /// The Action<T> to perform when the asynchronous GET method completes. + /// void GetForMessageAsync(string url, object[] uriVariables, Action>> getCompleted) where T : class; /// - /// Retrieve an entity by doing a GET on the specified URL. + /// Asynchronously retrieve an entity by doing a GET on the specified URL. /// The response is converted and stored in an . /// /// @@ -97,16 +105,20 @@ namespace Spring.Http.Rest /// The type of the response value. /// The URL. /// The dictionary containing variables for the URI template. - /// The HTTP response message. + /// + /// The Action<T> to perform when the asynchronous GET method completes. + /// void GetForMessageAsync(string url, IDictionary uriVariables, Action>> getCompleted) where T : class; /// - /// Retrieve an entity by doing a GET on the specified URL. + /// Asynchronously retrieve an entity by doing a GET on the specified URL. /// The response is converted and stored in an . /// /// The type of the response value. /// The URL. - /// The HTTP response message. + /// + /// The Action<T> to perform when the asynchronous GET method completes. + /// void GetForMessageAsync(Uri url, Action>> getCompleted) where T : class; #endregion @@ -114,32 +126,38 @@ namespace Spring.Http.Rest #region HEAD /// - /// Retrieve all headers of the resource specified by the URI template. + /// Asynchronously retrieve all headers of the resource specified by the URI template. /// /// /// URI Template variables are expanded using the given URI variables, if any. /// /// The URL. /// The variables to expand the template. - /// All HTTP headers of that resource + /// + /// The Action<T> to perform when the asynchronous HEAD method completes. + /// void HeadForHeadersAsync(string url, object[] uriVariables, Action> headCompleted); /// - /// Retrieve all headers of the resource specified by the URI template. + /// Asynchronously retrieve all headers of the resource specified by the URI template. /// /// /// URI Template variables are expanded using the given dictionary. /// /// The URL. /// The dictionary containing variables for the URI template. - /// All HTTP headers of that resource + /// + /// The Action<T> to perform when the asynchronous HEAD method completes. + /// void HeadForHeadersAsync(string url, IDictionary uriVariables, Action> headCompleted); /// - /// Retrieve all headers of the resource specified by the URI template. + /// Asynchronously retrieve all headers of the resource specified by the URI template. /// /// The URL. - /// All HTTP headers of that resource + /// + /// The Action<T> to perform when the asynchronous HEAD method completes. + /// void HeadForHeadersAsync(Uri url, Action> headCompleted); #endregion @@ -147,7 +165,7 @@ namespace Spring.Http.Rest #region POST /// - /// Create a new resource by POSTing the given object to the URI template, + /// Asynchronously create a new resource by POSTing the given object to the URI template, /// and returns the value of the 'Location' header. /// This header typically indicates where the new resource is stored. /// @@ -155,18 +173,19 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. - /// The value for the Location header. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// void PostForLocationAsync(string url, object request, object[] uriVariables, Action postCompleted); /// - /// Create a new resource by POSTing the given object to the URI template, + /// Asynchronously create a new resource by POSTing the given object to the URI template, /// and returns the value of the 'Location' header. /// This header typically indicates where the new resource is stored. /// @@ -174,177 +193,188 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. - /// The value for the Location header. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// void PostForLocationAsync(string url, object request, IDictionary uriVariables, Action postCompleted); /// - /// Create a new resource by POSTing the given object to the URI template, + /// Asynchronously create a new resource by POSTing the given object to the URI template, /// and returns the value of the 'Location' header. /// This header typically indicates where the new resource is stored. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The URL. - /// The Object to be POSTed, may be null. - /// The value for the Location header. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// void PostForLocationAsync(Uri url, object request, Action postCompleted); /// - /// Create a new resource by POSTing the given object to the URI template, + /// Asynchronously create a new resource by POSTing the given object to the URI template, /// and returns the representation found in the response. /// /// /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. - /// The converted object. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// void PostForObjectAsync(string url, object request, object[] uriVariables, Action> postCompleted) where T : class; /// - /// Create a new resource by POSTing the given object to the URI template, + /// Asynchronously create a new resource by POSTing the given object to the URI template, /// and returns the representation found in the response. /// /// /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. - /// The converted object. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// void PostForObjectAsync(string url, object request, IDictionary uriVariables, Action> postCompleted) where T : class; /// - /// Create a new resource by POSTing the given object to the URI template, + /// Asynchronously create a new resource by POSTing the given object to the URI template, /// and returns the representation found in the response. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. - /// The converted object. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// void PostForObjectAsync(Uri url, object request, Action> postCompleted) where T : class; /// - /// Create a new resource by POSTing the given object to the URI template, + /// Asynchronously create a new resource by POSTing the given object to the URI template, /// and returns the response as . /// /// /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. - /// The HTTP response message. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// void PostForMessageAsync(string url, object request, object[] uriVariables, Action>> postCompleted) where T : class; /// - /// Create a new resource by POSTing the given object to the URI template, + /// Asynchronously create a new resource by POSTing the given object to the URI template, /// and returns the response as . /// /// /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. - /// The HTTP response message. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// void PostForMessageAsync(string url, object request, IDictionary uriVariables, Action>> postCompleted) where T : class; /// - /// Create a new resource by POSTing the given object to the URI template, + /// Asynchronously create a new resource by POSTing the given object to the URI template, /// and returns the response as . /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. - /// The HTTP response message. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// void PostForMessageAsync(Uri url, object request, Action>> postCompleted) where T : class; /// - /// Create a new resource by POSTing the given object to the URI template, + /// Asynchronously create a new resource by POSTing the given object to the URI template, /// and returns the response with no entity as . /// /// /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. - /// The HTTP response message with no entity. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// void PostForMessageAsync(string url, object request, object[] uriVariables, Action> postCompleted); /// - /// Create a new resource by POSTing the given object to the URI template, + /// Asynchronously create a new resource by POSTing the given object to the URI template, /// and returns the response with no entity as . /// /// /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. - /// The HTTP response message with no entity. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// void PostForMessageAsync(string url, object request, IDictionary uriVariables, Action> postCompleted); /// - /// Create a new resource by POSTing the given object to the URI template, + /// Asynchronously create a new resource by POSTing the given object to the URI template, /// and returns the response with no entity as . /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The URL. - /// The Object to be POSTed, may be null. - /// The HTTP response message with no entity. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// void PostForMessageAsync(Uri url, object request, Action> postCompleted); #endregion @@ -352,45 +382,51 @@ namespace Spring.Http.Rest #region PUT /// - /// Create or update a resource by PUTting the given object to the URI. + /// Asynchronously create or update a resource by PUTting the given object to the URI. /// /// /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be PUT, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous PUT method completes. + /// void PutAsync(string url, object request, object[] uriVariables, Action> putCompleted); /// - /// Create or update a resource by PUTting the given object to the URI. + /// Asynchronously create or update a resource by PUTting the given object to the URI. /// /// /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be PUT, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous PUT method completes. + /// void PutAsync(string url, object request, IDictionary uriVariables, Action> putCompleted); /// - /// Create or update a resource by PUTting the given object to the URI. + /// Asynchronously create or update a resource by PUTting the given object to the URI. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The URL. - /// The Object to be PUT, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// + /// The Action<T> to perform when the asynchronous PUT method completes. + /// void PutAsync(Uri url, object request, Action> putCompleted); #endregion @@ -398,29 +434,38 @@ namespace Spring.Http.Rest #region DELETE /// - /// Delete the resources at the specified URI. + /// Asynchronously delete the resources at the specified URI. /// /// /// URI Template variables are expanded using the given URI variables, if any. /// /// The URL. /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous PUT method completes. + /// void DeleteAsync(string url, object[] uriVariables, Action> deleteCompleted); /// - /// Delete the resources at the specified URI. + /// Asynchronously delete the resources at the specified URI. /// /// /// URI Template variables are expanded using the given dictionary. /// /// The URL. /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous PUT method completes. + /// void DeleteAsync(string url, IDictionary uriVariables, Action> deleteCompleted); /// - /// Delete the resources at the specified URI. + /// Asynchronously delete the resources at the specified URI. /// /// The URL. + /// + /// The Action<T> to perform when the asynchronous PUT method completes. + /// void DeleteAsync(Uri url, Action> deleteCompleted); #endregion @@ -428,32 +473,38 @@ namespace Spring.Http.Rest #region OPTIONS /// - /// Return the value of the Allow header for the given URI. + /// Asynchronously return the value of the Allow header for the given URI. /// /// /// URI Template variables are expanded using the given URI variables, if any. /// /// The URL. /// The variables to expand the template. - /// The value of the allow header. + /// + /// The Action<T> to perform when the asynchronous OPTIONS method completes. + /// void OptionsForAllowAsync(string url, object[] uriVariables, Action> optionsCompleted); /// - /// Return the value of the Allow header for the given URI. + /// Asynchronously return the value of the Allow header for the given URI. /// /// /// URI Template variables are expanded using the given dictionary. /// /// The URL. /// The dictionary containing variables for the URI template. - /// The value of the allow header. + /// + /// The Action<T> to perform when the asynchronous OPTIONS method completes. + /// void OptionsForAllowAsync(string url, IDictionary uriVariables, Action> optionsCompleted); /// - /// Return the value of the Allow header for the given URI. + /// Asynchronously return the value of the Allow header for the given URI. /// /// The URL. - /// The value of the allow header. + /// + /// The Action<T> to perform when the asynchronous OPTIONS method completes. + /// void OptionsForAllowAsync(Uri url, Action> optionsCompleted); #endregion @@ -462,7 +513,7 @@ namespace Spring.Http.Rest #region Exchange /// - /// Execute the HTTP method to the given URI template, writing the given request message to the request, + /// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request, /// and returns the response as . /// /// @@ -475,11 +526,13 @@ namespace Spring.Http.Rest /// The HTTP entity (headers and/or body) to write to the request, may be . /// /// The variables to expand the template. - /// The HTTP response message. + /// + /// The Action<T> to perform when the asynchronous method completes. + /// void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, object[] uriVariables, Action>> methodCompleted) where T : class; /// - /// Execute the HTTP method to the given URI template, writing the given request message to the request, + /// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request, /// and returns the response as . /// /// @@ -492,11 +545,13 @@ namespace Spring.Http.Rest /// The HTTP entity (headers and/or body) to write to the request, may be . /// /// The dictionary containing variables for the URI template. - /// The HTTP response message. + /// + /// The Action<T> to perform when the asynchronous method completes. + /// void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables, Action>> methodCompleted) where T : class; /// - /// Execute the HTTP method to the given URI template, writing the given request message to the request, + /// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request, /// and returns the response as . /// /// The type of the response value. @@ -505,11 +560,13 @@ namespace Spring.Http.Rest /// /// The HTTP entity (headers and/or body) to write to the request, may be . /// - /// The HTTP response message. + /// + /// The Action<T> to perform when the asynchronous method completes. + /// void ExchangeAsync(Uri url, HttpMethod method, HttpEntity requestEntity, Action>> methodCompleted) where T : class; /// - /// Execute the HTTP method to the given URI template, writing the given request message to the request, + /// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request, /// and returns the response with no entity as . /// /// @@ -521,11 +578,13 @@ namespace Spring.Http.Rest /// The HTTP entity (headers and/or body) to write to the request, may be . /// /// The variables to expand the template. - /// The HTTP response message with no entity. + /// + /// The Action<T> to perform when the asynchronous method completes. + /// void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, object[] uriVariables, Action> methodCompleted); /// - /// Execute the HTTP method to the given URI template, writing the given request message to the request, + /// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request, /// and returns the response with no entity as . /// /// @@ -537,11 +596,13 @@ namespace Spring.Http.Rest /// The HTTP entity (headers and/or body) to write to the request, may be . /// /// The dictionary containing variables for the URI template. - /// The HTTP response message with no entity. + /// + /// The Action<T> to perform when the asynchronous method completes. + /// void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables, Action> methodCompleted); /// - /// Execute the HTTP method to the given URI template, writing the given request message to the request, + /// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request, /// and returns the response with no entity as . /// /// The URL. @@ -549,7 +610,9 @@ namespace Spring.Http.Rest /// /// The HTTP entity (headers and/or body) to write to the request, may be . /// - /// The HTTP response message with no entity. + /// + /// The Action<T> to perform when the asynchronous method completes. + /// void ExchangeAsync(Uri url, HttpMethod method, HttpEntity requestEntity, Action> methodCompleted); #endregion @@ -557,7 +620,7 @@ namespace Spring.Http.Rest #region General execution /// - /// Execute the HTTP method to the given URI template, preparing the request with the + /// Asynchronously execute the HTTP method to the given URI template, preparing the request with the /// , and reading the response with an . /// /// @@ -569,11 +632,13 @@ namespace Spring.Http.Rest /// Object that prepares the request. /// Object that extracts the return value from the response. /// The variables to expand the template. - /// An arbitrary object, as returned by the . + /// + /// The Action<T> to perform when the asynchronous method completes. + /// void ExecuteAsync(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, object[] uriVariables, Action> methodCompleted) where T : class; /// - /// Execute the HTTP method to the given URI template, preparing the request with the + /// Asynchronously execute the HTTP method to the given URI template, preparing the request with the /// , and reading the response with an . /// /// @@ -585,11 +650,13 @@ namespace Spring.Http.Rest /// Object that prepares the request. /// Object that extracts the return value from the response. /// The dictionary containing variables for the URI template. - /// An arbitrary object, as returned by the . + /// + /// The Action<T> to perform when the asynchronous method completes. + /// void ExecuteAsync(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, IDictionary uriVariables, Action> methodCompleted) where T : class; /// - /// Execute the HTTP method to the given URI template, preparing the request with the + /// Asynchronously execute the HTTP method to the given URI template, preparing the request with the /// , and reading the response with an . /// /// The type of the response value. @@ -597,7 +664,9 @@ namespace Spring.Http.Rest /// The HTTP method (GET, POST, etc.) /// Object that prepares the request. /// Object that extracts the return value from the response. - /// An arbitrary object, as returned by the . + /// + /// The Action<T> to perform when the asynchronous method completes. + /// void ExecuteAsync(Uri url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, Action> methodCompleted) where T : class; #endregion diff --git a/src/Spring/Spring.Http/Http/Rest/IRestOperations.cs b/src/Spring/Spring.Http/Http/Rest/IRestOperations.cs index 2e1fcecf..ccac7ac8 100644 --- a/src/Spring/Spring.Http/Http/Rest/IRestOperations.cs +++ b/src/Spring/Spring.Http/Http/Rest/IRestOperations.cs @@ -38,9 +38,6 @@ namespace Spring.Http.Rest /// Bruno Baia (.NET) public interface IRestOperations { - // TODO : use object[] instead of string[] - // TODO : use IDictionary instead of IDictionary - #region GET /// @@ -159,12 +156,11 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. /// The value for the Location header. Uri PostForLocation(string url, object request, params object[] uriVariables); @@ -178,12 +174,11 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. /// The value for the Location header. Uri PostForLocation(string url, object request, IDictionary uriVariables); @@ -193,11 +188,10 @@ namespace Spring.Http.Rest /// and returns the value of the 'Location' header. /// This header typically indicates where the new resource is stored. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The value for the Location header. Uri PostForLocation(Uri url, object request); @@ -209,13 +203,12 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. /// The converted object. T PostForObject(string url, object request, params object[] uriVariables) where T : class; @@ -228,13 +221,12 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. /// The converted object. T PostForObject(string url, object request, IDictionary uriVariables) where T : class; @@ -243,12 +235,11 @@ namespace Spring.Http.Rest /// Create a new resource by POSTing the given object to the URI template, /// and returns the representation found in the response. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The converted object. T PostForObject(Uri url, object request) where T : class; @@ -260,13 +251,12 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. /// The HTTP response message. HttpResponseMessage PostForMessage(string url, object request, params object[] uriVariables) where T : class; @@ -279,13 +269,12 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. /// The HTTP response message. HttpResponseMessage PostForMessage(string url, object request, IDictionary uriVariables) where T : class; @@ -294,12 +283,11 @@ namespace Spring.Http.Rest /// Create a new resource by POSTing the given object to the URI template, /// and returns the response as . /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The HTTP response message. HttpResponseMessage PostForMessage(Uri url, object request) where T : class; @@ -311,12 +299,11 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. /// The HTTP response message with no entity. HttpResponseMessage PostForMessage(string url, object request, params object[] uriVariables); @@ -329,12 +316,11 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. /// The HTTP response message with no entity. HttpResponseMessage PostForMessage(string url, object request, IDictionary uriVariables); @@ -343,11 +329,10 @@ namespace Spring.Http.Rest /// Create a new resource by POSTing the given object to the URI template, /// and returns the response with no entity as . /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The HTTP response message with no entity. HttpResponseMessage PostForMessage(Uri url, object request); @@ -362,12 +347,11 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be PUT, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. void Put(string url, object request, params object[] uriVariables); @@ -378,23 +362,21 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be PUT, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. void Put(string url, object request, IDictionary uriVariables); /// /// Create or update a resource by PUTting the given object to the URI. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The URL. - /// The Object to be PUT, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// void Put(Uri url, object request); #endregion diff --git a/src/Spring/Spring.Http/Http/Rest/MethodCompletedEventArgs.cs b/src/Spring/Spring.Http/Http/Rest/MethodCompletedEventArgs.cs index ba1e83d1..d32ea9a6 100644 --- a/src/Spring/Spring.Http/Http/Rest/MethodCompletedEventArgs.cs +++ b/src/Spring/Spring.Http/Http/Rest/MethodCompletedEventArgs.cs @@ -23,24 +23,42 @@ using System.ComponentModel; namespace Spring.Http.Rest { + // TODO: Rename this to RestOperationCompletedEventArgs or RestAsyncCompletedEventArgs ? + + /// + /// Provides data when an asynchronous REST operation completes. + /// + /// The type of the response value. + /// + /// public class MethodCompletedEventArgs : AsyncCompletedEventArgs where T : class { private T response; + /// + /// Gest the response of the REST operation. + /// + /// If the operation was canceled. + /// If the operation failed. public T Response { get { - // Raise an exception if the operation failed or - // was canceled. + // Raise an exception if the operation failed or was canceled. base.RaiseExceptionIfNecessary(); - // If the operation was successful, return the - // property value. + // If the operation was successful, return the value. return response; } } + /// + /// Creates a new instance of . + /// + /// The response of the REST operation. + /// Any error that occurred during the asynchronous operation. + /// A value indicating whether the asynchronous operation was canceled. + /// The optional user-supplied state object. public MethodCompletedEventArgs(T response, Exception exception, bool cancelled, object userState) : base(exception, cancelled, userState) { diff --git a/src/Spring/Spring.Http/Http/Rest/RestTemplate.cs b/src/Spring/Spring.Http/Http/Rest/RestTemplate.cs index f37d1eba..93605a38 100644 --- a/src/Spring/Spring.Http/Http/Rest/RestTemplate.cs +++ b/src/Spring/Spring.Http/Http/Rest/RestTemplate.cs @@ -412,12 +412,11 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. /// The value for the Location header. public Uri PostForLocation(string url, object request, params object[] uriVariables) @@ -437,12 +436,11 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. /// The value for the Location header. public Uri PostForLocation(string url, object request, IDictionary uriVariables) @@ -458,11 +456,10 @@ namespace Spring.Http.Rest /// and returns the value of the 'Location' header. /// This header typically indicates where the new resource is stored. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The value for the Location header. public Uri PostForLocation(Uri url, object request) { @@ -480,13 +477,12 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. /// The converted object. public T PostForObject(string url, object request, params object[] uriVariables) where T : class @@ -504,13 +500,12 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. /// The converted object. public T PostForObject(string url, object request, IDictionary uriVariables) where T : class @@ -524,12 +519,11 @@ namespace Spring.Http.Rest /// Create a new resource by POSTing the given object to the URI template, /// and returns the representation found in the response. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The converted object. public T PostForObject(Uri url, object request) where T : class { @@ -546,13 +540,12 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. /// The HTTP response message. public HttpResponseMessage PostForMessage(string url, object request, params object[] uriVariables) where T : class @@ -570,13 +563,12 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. /// The HTTP response message. public HttpResponseMessage PostForMessage(string url, object request, IDictionary uriVariables) where T : class @@ -590,12 +582,11 @@ namespace Spring.Http.Rest /// Create a new resource by POSTing the given object to the URI template, /// and returns the response as . /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The type of the response value. /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The HTTP response message. public HttpResponseMessage PostForMessage(Uri url, object request) where T : class { @@ -612,12 +603,11 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. /// The HTTP response message with no entity. public HttpResponseMessage PostForMessage(string url, object request, params object[] uriVariables) @@ -635,12 +625,11 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. /// The HTTP response message with no entity. public HttpResponseMessage PostForMessage(string url, object request, IDictionary uriVariables) @@ -654,11 +643,10 @@ namespace Spring.Http.Rest /// Create a new resource by POSTing the given object to the URI template, /// and returns the response with no entity as . /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The URL. - /// The Object to be POSTed, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The HTTP response message with no entity. public HttpResponseMessage PostForMessage(Uri url, object request) { @@ -678,12 +666,11 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given URI variables, if any. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be PUT, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The variables to expand the template. public void Put(string url, object request, params object[] uriVariables) { @@ -698,12 +685,11 @@ namespace Spring.Http.Rest /// /// URI Template variables are expanded using the given dictionary. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// /// The URL. - /// The Object to be PUT, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// /// The dictionary containing variables for the URI template. public void Put(string url, object request, IDictionary uriVariables) { @@ -714,11 +700,10 @@ namespace Spring.Http.Rest /// /// Create or update a resource by PUTting the given object to the URI. /// - /// - /// The request parameter can be a in order to add additional HTTP headers to the request. - /// /// The URL. - /// The Object to be PUT, may be null. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// public void Put(Uri url, object request) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); @@ -1004,6 +989,19 @@ namespace Spring.Http.Rest #region GET + /// + /// Asynchronously retrieve a representation by doing a GET on the specified URL. + /// The response (if any) is converted. + /// + /// + /// URI Template variables are expanded using the given URI variables, if any. + /// + /// The type of the response value. + /// The URL. + /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous GET method completes. + /// public void GetForObjectAsync(string url, object[] uriVariables, Action> getCompleted) where T : class { AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(typeof(T), this._messageConverters); @@ -1011,6 +1009,19 @@ namespace Spring.Http.Rest this.ExecuteAsync(url, HttpMethod.GET, requestCallback, responseExtractor, uriVariables, getCompleted); } + /// + /// Asynchronously retrieve a representation by doing a GET on the specified URL. + /// The response (if any) is converted. + /// + /// + /// URI Template variables are expanded using the given dictionary. + /// + /// The type of the response value. + /// The URL. + /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous GET method completes. + /// public void GetForObjectAsync(string url, IDictionary uriVariables, Action> getCompleted) where T : class { AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(typeof(T), this._messageConverters); @@ -1018,6 +1029,15 @@ namespace Spring.Http.Rest this.ExecuteAsync(url, HttpMethod.GET, requestCallback, responseExtractor, uriVariables, getCompleted); } + /// + /// Asynchronously retrieve a representation by doing a GET on the specified URL. + /// The response (if any) is converted. + /// + /// The type of the response value. + /// The URL. + /// + /// The Action<T> to perform when the asynchronous GET method completes. + /// public void GetForObjectAsync(Uri url, Action> getCompleted) where T : class { AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(typeof(T), this._messageConverters); @@ -1025,6 +1045,19 @@ namespace Spring.Http.Rest this.ExecuteAsync(url, HttpMethod.GET, requestCallback, responseExtractor, getCompleted); } + /// + /// Asynchronously retrieve an entity by doing a GET on the specified URL. + /// The response is converted and stored in an . + /// + /// + /// URI Template variables are expanded using the given URI variables, if any. + /// + /// The type of the response value. + /// The URL. + /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous GET method completes. + /// public void GetForMessageAsync(string url, object[] uriVariables, Action>> getCompleted) where T : class { AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(typeof(T), this._messageConverters); @@ -1032,6 +1065,19 @@ namespace Spring.Http.Rest this.ExecuteAsync>(url, HttpMethod.GET, requestCallback, responseExtractor, uriVariables, getCompleted); } + /// + /// Asynchronously retrieve an entity by doing a GET on the specified URL. + /// The response is converted and stored in an . + /// + /// + /// URI Template variables are expanded using the given dictionary. + /// + /// The type of the response value. + /// The URL. + /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous GET method completes. + /// public void GetForMessageAsync(string url, IDictionary uriVariables, Action>> getCompleted) where T : class { AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(typeof(T), this._messageConverters); @@ -1039,6 +1085,15 @@ namespace Spring.Http.Rest this.ExecuteAsync>(url, HttpMethod.GET, requestCallback, responseExtractor, uriVariables, getCompleted); } + /// + /// Asynchronously retrieve an entity by doing a GET on the specified URL. + /// The response is converted and stored in an . + /// + /// The type of the response value. + /// The URL. + /// + /// The Action<T> to perform when the asynchronous GET method completes. + /// public void GetForMessageAsync(Uri url, Action>> getCompleted) where T : class { AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(typeof(T), this._messageConverters); @@ -1050,16 +1105,45 @@ namespace Spring.Http.Rest #region HEAD + /// + /// Asynchronously retrieve all headers of the resource specified by the URI template. + /// + /// + /// URI Template variables are expanded using the given URI variables, if any. + /// + /// The URL. + /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous HEAD method completes. + /// public void HeadForHeadersAsync(string url, object[] uriVariables, Action> headCompleted) { this.ExecuteAsync(url, HttpMethod.HEAD, null, this.headersExtractor, uriVariables, headCompleted); } + /// + /// Asynchronously retrieve all headers of the resource specified by the URI template. + /// + /// + /// URI Template variables are expanded using the given dictionary. + /// + /// The URL. + /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous HEAD method completes. + /// public void HeadForHeadersAsync(string url, IDictionary uriVariables, Action> headCompleted) { this.ExecuteAsync(url, HttpMethod.HEAD, null, this.headersExtractor, uriVariables, headCompleted); } + /// + /// Asynchronously retrieve all headers of the resource specified by the URI template. + /// + /// The URL. + /// + /// The Action<T> to perform when the asynchronous HEAD method completes. + /// public void HeadForHeadersAsync(Uri url, Action> headCompleted) { this.ExecuteAsync(url, HttpMethod.HEAD, null, this.headersExtractor, headCompleted); @@ -1069,6 +1153,24 @@ namespace Spring.Http.Rest #region POST + /// + /// Asynchronously create a new resource by POSTing the given object to the URI template, + /// and returns the value of the 'Location' header. + /// This header typically indicates where the new resource is stored. + /// + /// + /// + /// URI Template variables are expanded using the given URI variables, if any. + /// + /// + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// public void PostForLocationAsync(string url, object request, object[] uriVariables, Action postCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); @@ -1079,6 +1181,24 @@ namespace Spring.Http.Rest }); } + /// + /// Asynchronously create a new resource by POSTing the given object to the URI template, + /// and returns the value of the 'Location' header. + /// This header typically indicates where the new resource is stored. + /// + /// + /// + /// URI Template variables are expanded using the given dictionary. + /// + /// + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// public void PostForLocationAsync(string url, object request, IDictionary uriVariables, Action postCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); @@ -1089,6 +1209,18 @@ namespace Spring.Http.Rest }); } + /// + /// Asynchronously create a new resource by POSTing the given object to the URI template, + /// and returns the value of the 'Location' header. + /// This header typically indicates where the new resource is stored. + /// + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// public void PostForLocationAsync(Uri url, object request, Action postCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); @@ -1099,6 +1231,24 @@ namespace Spring.Http.Rest }); } + /// + /// Asynchronously create a new resource by POSTing the given object to the URI template, + /// and returns the representation found in the response. + /// + /// + /// + /// URI Template variables are expanded using the given URI variables, if any. + /// + /// + /// The type of the response value. + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// public void PostForObjectAsync(string url, object request, object[] uriVariables, Action> postCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, typeof(T), this._messageConverters); @@ -1106,6 +1256,24 @@ namespace Spring.Http.Rest this.ExecuteAsync(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables, postCompleted); } + /// + /// Asynchronously create a new resource by POSTing the given object to the URI template, + /// and returns the representation found in the response. + /// + /// + /// + /// URI Template variables are expanded using the given dictionary. + /// + /// + /// The type of the response value. + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// public void PostForObjectAsync(string url, object request, IDictionary uriVariables, Action> postCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, typeof(T), this._messageConverters); @@ -1113,6 +1281,18 @@ namespace Spring.Http.Rest this.ExecuteAsync(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables, postCompleted); } + /// + /// Asynchronously create a new resource by POSTing the given object to the URI template, + /// and returns the representation found in the response. + /// + /// The type of the response value. + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// public void PostForObjectAsync(Uri url, object request, Action> postCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, typeof(T), this._messageConverters); @@ -1120,6 +1300,24 @@ namespace Spring.Http.Rest this.ExecuteAsync(url, HttpMethod.POST, requestCallback, responseExtractor, postCompleted); } + /// + /// Asynchronously create a new resource by POSTing the given object to the URI template, + /// and returns the response as . + /// + /// + /// + /// URI Template variables are expanded using the given URI variables, if any. + /// + /// + /// The type of the response value. + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// public void PostForMessageAsync(string url, object request, object[] uriVariables, Action>> postCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, typeof(T), this._messageConverters); @@ -1127,6 +1325,24 @@ namespace Spring.Http.Rest this.ExecuteAsync>(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables, postCompleted); } + /// + /// Asynchronously create a new resource by POSTing the given object to the URI template, + /// and returns the response as . + /// + /// + /// + /// URI Template variables are expanded using the given dictionary. + /// + /// + /// The type of the response value. + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// public void PostForMessageAsync(string url, object request, IDictionary uriVariables, Action>> postCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, typeof(T), this._messageConverters); @@ -1134,6 +1350,18 @@ namespace Spring.Http.Rest this.ExecuteAsync>(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables, postCompleted); } + /// + /// Asynchronously create a new resource by POSTing the given object to the URI template, + /// and returns the response as . + /// + /// The type of the response value. + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// public void PostForMessageAsync(Uri url, object request, Action>> postCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, typeof(T), this._messageConverters); @@ -1141,6 +1369,23 @@ namespace Spring.Http.Rest this.ExecuteAsync>(url, HttpMethod.POST, requestCallback, responseExtractor, postCompleted); } + /// + /// Asynchronously create a new resource by POSTing the given object to the URI template, + /// and returns the response with no entity as . + /// + /// + /// + /// URI Template variables are expanded using the given URI variables, if any. + /// + /// + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// public void PostForMessageAsync(string url, object request, object[] uriVariables, Action> postCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); @@ -1148,6 +1393,23 @@ namespace Spring.Http.Rest this.ExecuteAsync(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables, postCompleted); } + /// + /// Asynchronously create a new resource by POSTing the given object to the URI template, + /// and returns the response with no entity as . + /// + /// + /// + /// URI Template variables are expanded using the given dictionary. + /// + /// + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// public void PostForMessageAsync(string url, object request, IDictionary uriVariables, Action> postCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); @@ -1155,6 +1417,17 @@ namespace Spring.Http.Rest this.ExecuteAsync(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables, postCompleted); } + /// + /// Asynchronously create a new resource by POSTing the given object to the URI template, + /// and returns the response with no entity as . + /// + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// + /// The Action<T> to perform when the asynchronous POST method completes. + /// public void PostForMessageAsync(Uri url, object request, Action> postCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); @@ -1166,18 +1439,60 @@ namespace Spring.Http.Rest #region PUT + /// + /// Asynchronously create or update a resource by PUTting the given object to the URI. + /// + /// + /// + /// URI Template variables are expanded using the given URI variables, if any. + /// + /// + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous PUT method completes. + /// public void PutAsync(string url, object request, object[] uriVariables, Action> putCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); this.ExecuteAsync(url, HttpMethod.PUT, requestCallback, null, uriVariables, putCompleted); } + /// + /// Asynchronously create or update a resource by PUTting the given object to the URI. + /// + /// + /// + /// URI Template variables are expanded using the given dictionary. + /// + /// + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous PUT method completes. + /// public void PutAsync(string url, object request, IDictionary uriVariables, Action> putCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); this.ExecuteAsync(url, HttpMethod.PUT, requestCallback, null, uriVariables, putCompleted); } + /// + /// Asynchronously create or update a resource by PUTting the given object to the URI. + /// + /// The URL. + /// + /// The object to be POSTed, may be a in order to add additional HTTP headers. + /// + /// + /// The Action<T> to perform when the asynchronous PUT method completes. + /// public void PutAsync(Uri url, object request, Action> putCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); @@ -1188,16 +1503,45 @@ namespace Spring.Http.Rest #region DELETE + /// + /// Asynchronously delete the resources at the specified URI. + /// + /// + /// URI Template variables are expanded using the given URI variables, if any. + /// + /// The URL. + /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous PUT method completes. + /// public void DeleteAsync(string url, object[] uriVariables, Action> deleteCompleted) { this.ExecuteAsync(url, HttpMethod.DELETE, null, null, uriVariables, deleteCompleted); } + /// + /// Asynchronously delete the resources at the specified URI. + /// + /// + /// URI Template variables are expanded using the given dictionary. + /// + /// The URL. + /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous PUT method completes. + /// public void DeleteAsync(string url, IDictionary uriVariables, Action> deleteCompleted) { this.ExecuteAsync(url, HttpMethod.DELETE, null, null, uriVariables, deleteCompleted); } + /// + /// Asynchronously delete the resources at the specified URI. + /// + /// The URL. + /// + /// The Action<T> to perform when the asynchronous PUT method completes. + /// public void DeleteAsync(Uri url, Action> deleteCompleted) { this.ExecuteAsync(url, HttpMethod.DELETE, null, null, deleteCompleted); @@ -1207,6 +1551,17 @@ namespace Spring.Http.Rest #region OPTIONS + /// + /// Asynchronously return the value of the Allow header for the given URI. + /// + /// + /// URI Template variables are expanded using the given URI variables, if any. + /// + /// The URL. + /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous OPTIONS method completes. + /// public void OptionsForAllowAsync(string url, object[] uriVariables, Action> optionsCompleted) { this.ExecuteAsync(url, HttpMethod.OPTIONS, null, this.headersExtractor, uriVariables, @@ -1216,6 +1571,17 @@ namespace Spring.Http.Rest }); } + /// + /// Asynchronously return the value of the Allow header for the given URI. + /// + /// + /// URI Template variables are expanded using the given dictionary. + /// + /// The URL. + /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous OPTIONS method completes. + /// public void OptionsForAllowAsync(string url, IDictionary uriVariables, Action> optionsCompleted) { this.ExecuteAsync(url, HttpMethod.OPTIONS, null, this.headersExtractor, uriVariables, @@ -1225,6 +1591,13 @@ namespace Spring.Http.Rest }); } + /// + /// Asynchronously return the value of the Allow header for the given URI. + /// + /// The URL. + /// + /// The Action<T> to perform when the asynchronous OPTIONS method completes. + /// public void OptionsForAllowAsync(Uri url, Action> optionsCompleted) { this.ExecuteAsync(url, HttpMethod.OPTIONS, null, this.headersExtractor, @@ -1239,6 +1612,23 @@ namespace Spring.Http.Rest #region Exchange + /// + /// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request, + /// and returns the response as . + /// + /// + /// URI Template variables are expanded using the given URI variables, if any. + /// + /// The type of the response value. + /// The URL. + /// The HTTP method (GET, POST, etc.) + /// + /// The HTTP entity (headers and/or body) to write to the request, may be . + /// + /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous method completes. + /// public void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, object[] uriVariables, Action>> methodCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, typeof(T), this._messageConverters); @@ -1246,6 +1636,23 @@ namespace Spring.Http.Rest this.ExecuteAsync>(url, method, requestCallback, responseExtractor, uriVariables, methodCompleted); } + /// + /// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request, + /// and returns the response as . + /// + /// + /// URI Template variables are expanded using the given dictionary. + /// + /// The type of the response value. + /// The URL. + /// The HTTP method (GET, POST, etc.) + /// + /// The HTTP entity (headers and/or body) to write to the request, may be . + /// + /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous method completes. + /// public void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables, Action>> methodCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, typeof(T), this._messageConverters); @@ -1253,6 +1660,19 @@ namespace Spring.Http.Rest this.ExecuteAsync>(url, method, requestCallback, responseExtractor, uriVariables, methodCompleted); } + /// + /// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request, + /// and returns the response as . + /// + /// The type of the response value. + /// The URL. + /// The HTTP method (GET, POST, etc.) + /// + /// The HTTP entity (headers and/or body) to write to the request, may be . + /// + /// + /// The Action<T> to perform when the asynchronous method completes. + /// public void ExchangeAsync(Uri url, HttpMethod method, HttpEntity requestEntity, Action>> methodCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, typeof(T), this._messageConverters); @@ -1260,6 +1680,22 @@ namespace Spring.Http.Rest this.ExecuteAsync>(url, method, requestCallback, responseExtractor, methodCompleted); } + /// + /// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request, + /// and returns the response with no entity as . + /// + /// + /// URI Template variables are expanded using the given URI variables, if any. + /// + /// The URL. + /// The HTTP method (GET, POST, etc.) + /// + /// The HTTP entity (headers and/or body) to write to the request, may be . + /// + /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous method completes. + /// public void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, object[] uriVariables, Action> methodCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, this._messageConverters); @@ -1267,6 +1703,22 @@ namespace Spring.Http.Rest this.ExecuteAsync(url, method, requestCallback, responseExtractor, uriVariables, methodCompleted); } + /// + /// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request, + /// and returns the response with no entity as . + /// + /// + /// URI Template variables are expanded using the given dictionary. + /// + /// The URL. + /// The HTTP method (GET, POST, etc.) + /// + /// The HTTP entity (headers and/or body) to write to the request, may be . + /// + /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous method completes. + /// public void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables, Action> methodCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, this._messageConverters); @@ -1274,6 +1726,18 @@ namespace Spring.Http.Rest this.ExecuteAsync(url, method, requestCallback, responseExtractor, uriVariables, methodCompleted); } + /// + /// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request, + /// and returns the response with no entity as . + /// + /// The URL. + /// The HTTP method (GET, POST, etc.) + /// + /// The HTTP entity (headers and/or body) to write to the request, may be . + /// + /// + /// The Action<T> to perform when the asynchronous method completes. + /// public void ExchangeAsync(Uri url, HttpMethod method, HttpEntity requestEntity, Action> methodCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, this._messageConverters); @@ -1285,18 +1749,62 @@ namespace Spring.Http.Rest #region General execution + /// + /// Asynchronously execute the HTTP method to the given URI template, preparing the request with the + /// , and reading the response with an . + /// + /// + /// URI Template variables are expanded using the given URI variables, if any. + /// + /// The type of the response value. + /// The URL. + /// The HTTP method (GET, POST, etc.) + /// Object that prepares the request. + /// Object that extracts the return value from the response. + /// The variables to expand the template. + /// + /// The Action<T> to perform when the asynchronous method completes. + /// public void ExecuteAsync(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, object[] uriVariables, Action> methodCompleted) where T : class { this.DoExecuteAsync(BuildUri(this._baseAddress, url, uriVariables), method, requestCallback, responseExtractor, methodCompleted); } + /// + /// Asynchronously execute the HTTP method to the given URI template, preparing the request with the + /// , and reading the response with an . + /// + /// + /// URI Template variables are expanded using the given dictionary. + /// + /// The type of the response value. + /// The URL. + /// The HTTP method (GET, POST, etc.) + /// Object that prepares the request. + /// Object that extracts the return value from the response. + /// The dictionary containing variables for the URI template. + /// + /// The Action<T> to perform when the asynchronous method completes. + /// public void ExecuteAsync(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, IDictionary uriVariables, Action> methodCompleted) where T : class { this.DoExecuteAsync(BuildUri(this._baseAddress, url, uriVariables), method, requestCallback, responseExtractor, methodCompleted); } + /// + /// Asynchronously execute the HTTP method to the given URI template, preparing the request with the + /// , and reading the response with an . + /// + /// The type of the response value. + /// The URL. + /// The HTTP method (GET, POST, etc.) + /// Object that prepares the request. + /// Object that extracts the return value from the response. + /// + /// The Action<T> to perform when the asynchronous method completes. + /// public void ExecuteAsync(Uri url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, Action> methodCompleted) where T : class { this.DoExecuteAsync(BuildUri(this._baseAddress, url), method, @@ -1308,6 +1816,7 @@ namespace Spring.Http.Rest #endregion #region DoExecute + #if !SILVERLIGHT /// /// Execute the HTTP request to the given URI, preparing the request with the @@ -1351,12 +1860,23 @@ namespace Spring.Http.Rest return null; } #endif + #endregion #region DoExecuteAsync + /// + /// Asynchronously execute the HTTP request to the given URI, preparing the request with the + /// , and reading the response with an . + /// + /// The type of the response value. /// The fully-expanded URI to connect to. /// The HTTP method (GET, POST, etc.) + /// Object that prepares the request. + /// Object that extracts the return value from the response. + /// + /// The Action<T> to perform when the asynchronous method completes. + /// protected virtual void DoExecuteAsync(Uri uri, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, Action> methodCompleted) where T : class @@ -1370,7 +1890,14 @@ namespace Spring.Http.Rest requestCallback.DoWithRequest(request); } - request.ExecuteAsync(state, ResponseReceivedCallback); + if (methodCompleted == null) + { + request.ExecuteAsync(null, null); + } + else + { + request.ExecuteAsync(state, ResponseReceivedCallback); + } } private void ResponseReceivedCallback(ExecuteCompletedEventArgs responseReceived) where T : class @@ -1448,6 +1975,14 @@ namespace Spring.Http.Rest // - UriTemplate.BindByPosition is not supported in Silverlight // - UriTemplate class is not included in the Silverlight core dlls + /// + /// Builds an uri using the given parameters. + /// + /// The base address to use, may be . + /// An absolute or relative URI template to expand. + /// The variables to expand the template. + /// The absolute build URI. + /// If an absolute URI can't be build. protected virtual Uri BuildUri(Uri baseAddress, string url, object[] uriVariables) { UriTemplate uriTemplate = new UriTemplate(url); @@ -1455,6 +1990,14 @@ namespace Spring.Http.Rest return BuildUri(baseAddress, uri); } + /// + /// Builds an uri using the given parameters. + /// + /// The base address to use, may be . + /// An absolute or relative URI template to expand. + /// The dictionary containing variables for the URI template. + /// The absolute build URI. + /// If an absolute URI can't be build. protected virtual Uri BuildUri(Uri baseAddress, string url, IDictionary uriVariables) { UriTemplate uriTemplate = new UriTemplate(url); @@ -1462,6 +2005,13 @@ namespace Spring.Http.Rest return BuildUri(baseAddress, uri); } + /// + /// Builds an uri using the given parameters. + /// + /// The base address to use, may be . + /// An absolute or relative URI. + /// The absolute build URI. + /// If an absolute URI can't be build. protected virtual Uri BuildUri(Uri baseAddress, Uri uri) { if (!uri.IsAbsoluteUri) diff --git a/src/Spring/Spring.Http/Util/AssertUtils.cs b/src/Spring/Spring.Http/Util/AssertUtils.cs index d606a249..4c6e425d 100644 --- a/src/Spring/Spring.Http/Util/AssertUtils.cs +++ b/src/Spring/Spring.Http/Util/AssertUtils.cs @@ -23,6 +23,8 @@ using System.Globalization; namespace Spring.Util { + // From Spring.Core + /// /// Assertion utility methods that simplify things such as argument checks. /// diff --git a/src/Spring/Spring.Http/Util/StringUtils.cs b/src/Spring/Spring.Http/Util/StringUtils.cs index a8df3869..3a726e8d 100644 --- a/src/Spring/Spring.Http/Util/StringUtils.cs +++ b/src/Spring/Spring.Http/Util/StringUtils.cs @@ -22,6 +22,8 @@ using System; namespace Spring.Util { + // From Spring.Core + /// /// Miscellaneous utility methods. /// diff --git a/test/Spring/Spring.Http.Tests/Http/Converters/FormHttpMessageConverterTests.cs b/test/Spring/Spring.Http.Tests/Http/Converters/FormHttpMessageConverterTests.cs index 3b7f0f23..22ed1ce6 100644 --- a/test/Spring/Spring.Http.Tests/Http/Converters/FormHttpMessageConverterTests.cs +++ b/test/Spring/Spring.Http.Tests/Http/Converters/FormHttpMessageConverterTests.cs @@ -129,7 +129,7 @@ namespace Spring.Http.Converters } [Test] - [Ignore] //TODO: relative path + [Ignore] //TODO: relative path (needs IResource ?) public void WriteMultipart() { MemoryStream requestStream = new MemoryStream();