Skip to content

Commit

Permalink
Added new GetResponse method overloads to IHttpClient and HttpClient
Browse files Browse the repository at this point in the history
The overloads takes an instance of IHttpRequest as it's only parameter, and then returns the IHttpResponse from the generated request.
  • Loading branch information
abjerner committed Dec 29, 2021
1 parent 4145250 commit fd620c4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/Skybrud.Essentials.Http/Client/HttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,17 @@ public virtual IHttpResponse GetResponse(IHttpRequestOptions options) {
return request.GetResponse();
}

/// <summary>
/// Sends a new request as described by <paramref name="request"/> and returns the response.
/// </summary>
/// <param name="request">An instance of <see cref="IHttpRequest"/> describing the request.</param>
/// <returns>An instanceo of <see cref="IHttpResponse"/> representing the raw response.</returns>
public virtual IHttpResponse GetResponse(IHttpRequest request) {
if (request == null) throw new ArgumentNullException(nameof(request));
PrepareHttpRequest(request);
return request.GetResponse();
}

/// <summary>
/// Virtual method that can be used for configuring a request.
/// </summary>
Expand Down
9 changes: 8 additions & 1 deletion src/Skybrud.Essentials.Http/Client/IHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Skybrud.Essentials.Http.Options;

namespace Skybrud.Essentials.Http.Client {

/// <summary>
/// Interface describing a client for making HTTP requests.
/// </summary>
Expand All @@ -18,6 +18,13 @@ public interface IHttpClient {
/// <returns>An instanceo of <see cref="IHttpResponse"/> representing the raw response.</returns>
IHttpResponse GetResponse(IHttpRequestOptions options);

/// <summary>
/// Sends a new request as described by <paramref name="request"/> and returns the response.
/// </summary>
/// <param name="request">An instance of <see cref="IHttpRequest"/> describing the request.</param>
/// <returns>An instanceo of <see cref="IHttpResponse"/> representing the raw response.</returns>
IHttpResponse GetResponse(IHttpRequest request);

#region DoHttpGetRequest

/// <summary>
Expand Down

0 comments on commit fd620c4

Please sign in to comment.