-
Notifications
You must be signed in to change notification settings - Fork 314
Enable User Agent Extension #3606
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
base: main
Are you sure you want to change the base?
Changes from all commits
a144ef6
13090ce
8359565
c450c61
c8897d3
c0eea2b
26dd6f9
8ad3c69
2184035
af1eeb1
3b51844
ff39552
2394a2f
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 |
---|---|---|
|
@@ -59,11 +59,26 @@ public delegate void OnAuthenticationCompletedDelegate( | |
/// </summary> | ||
public byte ServerSupportedVectorFeatureExtVersion { get; set; } = DefaultSupportedVectorFeatureExtVersion; | ||
|
||
/// <summary> | ||
/// Property for setting server version for user agent feature extension. | ||
/// </summary> | ||
public byte ServerSupportedUserAgentFeatureExtVersion { get; set; } = DefaultSupportedUserAgentFeatureExtVersion; | ||
|
||
/// <summary> | ||
/// Client version for vector FeatureExtension. | ||
/// </summary> | ||
private byte _clientSupportedVectorFeatureExtVersion = 0; | ||
|
||
/// <summary> | ||
/// Server will ACK UserAgentSupport in the login response when this property is set to true. | ||
/// </summary> | ||
public bool EmitUserAgentFeatureExtAck { get; set; } = false; | ||
|
||
/// <summary> | ||
/// Default feature extension version supported on the server for user agent. | ||
/// </summary> | ||
public const byte DefaultSupportedUserAgentFeatureExtVersion = 0x01; | ||
|
||
/// <summary> | ||
/// Session counter | ||
/// </summary> | ||
|
@@ -654,6 +669,30 @@ protected virtual TDSMessageCollection OnAuthenticationCompleted(ITDSServerSessi | |
} | ||
} | ||
|
||
// If tests request it, force an ACK for UserAgentSupport with no negotiation | ||
if (EmitUserAgentFeatureExtAck) | ||
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. Can you please rewrite this large method to split these conditional blocks into individual methods? 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. Should you not be reading session instance value here as done above for other feature ext tokens? |
||
{ | ||
byte ackVersion = ServerSupportedUserAgentFeatureExtVersion; | ||
|
||
var data = new byte[] { ackVersion }; | ||
var uaAck = new TDSFeatureExtAckGenericOption( | ||
TDSFeatureID.UserAgentSupport, | ||
(uint)data.Length, | ||
data); | ||
|
||
// Reuse an existing FeatureExtAck token if present, otherwise add a new one | ||
var featureExtAckToken = responseMessage.OfType<TDSFeatureExtAckToken>().FirstOrDefault(); | ||
if (featureExtAckToken == null) | ||
{ | ||
featureExtAckToken = new TDSFeatureExtAckToken(uaAck); | ||
responseMessage.Add(featureExtAckToken); | ||
} | ||
else | ||
{ | ||
featureExtAckToken.Options.Add(uaAck); | ||
} | ||
} | ||
|
||
// Create DONE token | ||
TDSDoneToken doneToken = new TDSDoneToken(TDSDoneTokenStatusType.Final); | ||
|
||
|
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.
Just an observation - nothing for you to address here right now.
This approach of pre-calculating the packet length is inefficient. We're making 2 passes over the data to be written. Instead, we should be writing everything to the buffer once, leaving a hole where the header length goes, calculating the length as we write the data, and then going back at the end to fill in the header's length field.
I wonder if we're similarly inefficient for the other TDS packets/messages we write?
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.
I will leave a comment here so that we can follow up and investigate a bit later.
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.
Has this been addressed?