-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Simplifying and unifying every Base class constructors to go via comm… #4529
Conversation
shahabhijeet
commented
Jul 6, 2018
- Simplifying and unifying every Base class constructors to go via common code path.
- Simplifying logic to avoid adding duplicate userAgent strings.
- Making sure we use ConfigureAwait(false) where it was missing.
- Adding tests
…on code path. Simplifying logic to avoid adding duplicate userAgent strings. Making sure we use ConfigureAwait(false) where it was missing. Adding tests.
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.
foreach(ProductInfoHeaderValue piHv in defaultUserAgentInfoList) | ||
{ | ||
if(!HttpClient.DefaultRequestHeaders.UserAgent.Any<ProductInfoHeaderValue>((hv) => hv.Product.Name.Equals(piHv.Product.Name, StringComparison.OrdinalIgnoreCase))); | ||
if(!HttpClient.DefaultRequestHeaders.UserAgent.Any<ProductInfoHeaderValue>((hv) => hv.Product.Name.Equals(piHv.Product.Name, StringComparison.OrdinalIgnoreCase))) |
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.
This does not account for UserAgent strings that are comments only. They will NOT have a .Product property... this will throw a null reference exception. If this constructor is used https://technet.microsoft.com/en-us/library/hh138008(v=vs.110) then ProductInfoHeaderValue will have only a comment.
private void AddUserAgentEntry(ProductInfoHeaderValue pInfoHeaderValue) | ||
{ | ||
if (!HttpClient.DefaultRequestHeaders.UserAgent.Contains<ProductInfoHeaderValue>(pInfoHeaderValue, | ||
new ObjectComparer<ProductInfoHeaderValue>((left, right) => left.Product.Name.Equals(right.Product.Name, StringComparison.OrdinalIgnoreCase)))) |
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.
This does not account for UserAgent strings that are comments only. They will NOT have a .Product property... this will throw a null reference exception.
{ | ||
} | ||
|
||
: this(serviceHttpClient: null, rootHandler: CreateRootHandler(), disposeHttpClient: true, delHandlers: null) { } |
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.
CreateRootHandler is called by this constructor. This code creates a HttpClientHandler or WebRequestHandler that is then never disposed. Please see #3712