-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support providing the HttpClient direct to the FhirClient #2049
Changes from 3 commits
48f7af0
a5e534c
354323f
57591d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,7 +6,6 @@ | |||||||||||||||||
* available at https://raw.githubusercontent.com/FirelyTeam/firely-net-sdk/master/LICENSE | ||||||||||||||||||
*/ | ||||||||||||||||||
|
||||||||||||||||||
using Hl7.Fhir.Model; | ||||||||||||||||||
using Hl7.Fhir.Serialization; | ||||||||||||||||||
using Hl7.Fhir.Specification; | ||||||||||||||||||
using System; | ||||||||||||||||||
|
@@ -19,15 +18,16 @@ namespace Hl7.Fhir.Rest | |||||||||||||||||
{ | ||||||||||||||||||
public partial class FhirClient : BaseFhirClient | ||||||||||||||||||
{ | ||||||||||||||||||
//disables warning that OnBeforeRequest and OnAfterResponse are never used. | ||||||||||||||||||
//disables warning that OnBeforeRequest and OnAfterResponse are never used. | ||||||||||||||||||
#pragma warning disable CS0067 | ||||||||||||||||||
|
||||||||||||||||||
/// <summary> | ||||||||||||||||||
/// Creates a new client using a default endpoint | ||||||||||||||||||
/// If the endpoint does not end with a slash (/), it will be added. | ||||||||||||||||||
/// </summary> | ||||||||||||||||||
/// <remarks> | ||||||||||||||||||
/// If the messageHandler is provided then it must be disposed by the caller | ||||||||||||||||||
/// If the messageHandler, or httpClient is provided then it must be disposed by the caller | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Suggested change
|
||||||||||||||||||
/// Only one of the messageHandler or httpClient can be provided | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Suggested change
brianpos marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
/// </remarks> | ||||||||||||||||||
/// <param name="endpoint"> | ||||||||||||||||||
/// The URL of the server to connect to.<br/> | ||||||||||||||||||
|
@@ -38,19 +38,42 @@ public partial class FhirClient : BaseFhirClient | |||||||||||||||||
/// <param name="provider"></param> | ||||||||||||||||||
public FhirClient(Uri endpoint, FhirClientSettings settings = null, HttpMessageHandler messageHandler = null, IStructureDefinitionSummaryProvider provider = null) : base(endpoint, settings, provider) | ||||||||||||||||||
{ | ||||||||||||||||||
// If user does not supply message handler, add decompression strategy in default handler. | ||||||||||||||||||
// If user does not supply message handler, create our own and add decompression strategy in default handler. | ||||||||||||||||||
var handler = messageHandler ?? new HttpClientHandler() | ||||||||||||||||||
{ | ||||||||||||||||||
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate | ||||||||||||||||||
}; | ||||||||||||||||||
|
||||||||||||||||||
var requester = new HttpClientRequester(Endpoint, Settings, handler, messageHandler == null); | ||||||||||||||||||
HttpClientRequester requester = new HttpClientRequester(Endpoint, Settings, handler, messageHandler == null); | ||||||||||||||||||
Requester = requester; | ||||||||||||||||||
|
||||||||||||||||||
// Expose default request headers to user. | ||||||||||||||||||
RequestHeaders = requester.Client.DefaultRequestHeaders; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
/// <summary> | ||||||||||||||||||
/// Creates a new client using a default endpoint | ||||||||||||||||||
/// If the endpoint does not end with a slash (/), it will be added. | ||||||||||||||||||
/// </summary> | ||||||||||||||||||
/// <remarks> | ||||||||||||||||||
/// If the messageHandler, or httpClient is provided then it must be disposed by the caller | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Suggested change
|
||||||||||||||||||
/// Only one of the messageHandler or httpClient can be provided | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Suggested change
|
||||||||||||||||||
/// </remarks> | ||||||||||||||||||
/// <param name="endpoint"> | ||||||||||||||||||
/// The URL of the server to connect to.<br/> | ||||||||||||||||||
/// If the trailing '/' is not present, then it will be appended automatically | ||||||||||||||||||
/// </param> | ||||||||||||||||||
/// <param name="settings"></param> | ||||||||||||||||||
/// <param name="httpClient"></param> | ||||||||||||||||||
/// <param name="provider"></param> | ||||||||||||||||||
public FhirClient(Uri endpoint, HttpClient httpClient, FhirClientSettings settings = null, IStructureDefinitionSummaryProvider provider = null) : base(endpoint, settings, provider) | ||||||||||||||||||
{ | ||||||||||||||||||
HttpClientRequester requester = new HttpClientRequester(Endpoint, Settings, httpClient); | ||||||||||||||||||
Requester = requester; | ||||||||||||||||||
|
||||||||||||||||||
// Expose default request headers to user. | ||||||||||||||||||
RequestHeaders = requester.Client.DefaultRequestHeaders; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
/// <summary> | ||||||||||||||||||
/// Creates a new client using a default endpoint | ||||||||||||||||||
|
@@ -68,6 +91,22 @@ public FhirClient(string endpoint, FhirClientSettings settings = null, HttpMessa | |||||||||||||||||
{ | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
/// <summary> | ||||||||||||||||||
/// Creates a new client using a default endpoint | ||||||||||||||||||
/// If the endpoint does not end with a slash (/), it will be added. | ||||||||||||||||||
/// </summary> | ||||||||||||||||||
/// <param name="endpoint"> | ||||||||||||||||||
/// The URL of the server to connect to.<br/> | ||||||||||||||||||
/// If the trailing '/' is not present, then it will be appended automatically | ||||||||||||||||||
/// </param> | ||||||||||||||||||
/// <param name="settings"></param> | ||||||||||||||||||
/// <param name="httpClient"></param> | ||||||||||||||||||
/// <param name="provider"></param> | ||||||||||||||||||
public FhirClient(string endpoint, HttpClient httpClient, FhirClientSettings settings = null, IStructureDefinitionSummaryProvider provider = null) | ||||||||||||||||||
: this(new Uri(endpoint), httpClient, settings, provider) | ||||||||||||||||||
{ | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
/// <summary> | ||||||||||||||||||
/// Default request headers that can be modified to persist default headers to internal client. | ||||||||||||||||||
/// </summary> | ||||||||||||||||||
|
@@ -178,7 +217,7 @@ public ParserSettings ParserSettings | |||||||||||||||||
} | ||||||||||||||||||
#endregion | ||||||||||||||||||
|
||||||||||||||||||
[Obsolete ("OnBeforeRequest is deprecated, please add a HttpClientEventHandler or another HttpMessageHandler to the constructor to use this functionality", true)] | ||||||||||||||||||
[Obsolete("OnBeforeRequest is deprecated, please add a HttpClientEventHandler or another HttpMessageHandler to the constructor to use this functionality", true)] | ||||||||||||||||||
public event EventHandler<BeforeHttpRequestEventArgs> OnBeforeRequest; | ||||||||||||||||||
|
||||||||||||||||||
[Obsolete("OnAfterResponse is deprecated, please add a HttpClientEventHandler or another HttpMessageHandler to the constructor to use this functionality", true)] | ||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.