@@ -21,7 +21,7 @@ public partial class GeneratedRelationalAIClient
2121
2222 public const string JSON_CONTENT_TYPE = "application/json" ;
2323 public const string CSV_CONTENT_TYPE = "text/csv" ;
24- public const string USER_AGENT_HEADER = "KGMSClient/1.2.3 /csharp" ;
24+ public const string USER_AGENT_HEADER = "KGMSClient/1.2.4 /csharp" ;
2525
2626 public int DebugLevel = Connection . DEFAULT_DEBUG_LEVEL ;
2727
@@ -55,10 +55,10 @@ partial void PrepareRequest(Transaction body, HttpClient client, HttpRequestMess
5555 // Note:
5656 // We need to send the gzip content encoding header and a gzip compressed body only in case of a CloudConnection.
5757 // Local rai-server cannot handle gzip encoding, only infra server support does.
58-
59- // Compress the contents (request body) as gzipped byte array. C# httpclient does not implicitly compress the content over the wire
58+
59+ // Compress the contents (request body) as gzipped byte array. C# httpclient does not implicitly compress the content over the wire
6060 // if content encoding is gzip; we need to manually compress the body.
61- // Note: If the client sends content-encoding as gzip but does not encode the content to gzip, then the server will return 400 Bad Request.
61+ // Note: If the client sends content-encoding as gzip but does not encode the content to gzip, then the server will return 400 Bad Request.
6262 request . Content = CompressionUtils . CompressRequestContentAsGzip ( request . Content ) ;
6363 //Set the content encoding type header as gzip. It will tell the server that the content is gzip encoded.
6464 request . Content . Headers . Add ( "content-encoding" , "gzip" ) ;
@@ -70,7 +70,7 @@ partial void PrepareRequest(Transaction body, HttpClient client, HttpRequestMess
7070 request . Headers . Host = request . RequestUri . Host ;
7171 //Set the content type header
7272 request . Content . Headers . ContentType = MediaTypeHeaderValue . Parse ( "application/json; charset=utf-8" ) ;
73-
73+
7474 // Set Auth here
7575 var raiRequest = new RAIRequest ( request , conn ) ;
7676 raiRequest . SetAuth ( ) ;
@@ -85,7 +85,7 @@ partial void PrepareRequest(Transaction body, HttpClient client, HttpRequestMess
8585 AsyncLocalKeepAliveCancellationTokenSource . Value = tokenSource ;
8686 CancellationToken ct = tokenSource . Token ;
8787
88- /**
88+ /**
8989 * TODO: currently we swallo exceptions in KeepClientAlive.
9090 * If we want to throw, then we need to change this to asynchronously handle the throw
9191 * e.g.
@@ -347,6 +347,7 @@ public override string ToString()
347347 public class KGMSClient : GeneratedRelationalAIClient
348348 {
349349 public static ILogger DefaultLogger = new ConsoleLogger ( ) ;
350+ public static IDictionary < String , String > extraHeaders = new Dictionary < String , String > ( ) ;
350351
351352 public ILogger Logger
352353 {
@@ -366,7 +367,7 @@ public override async Task KeepClientAlive(HttpClient client_, String url, Cance
366367 try {
367368 await Task . Run ( ( ) => this . KeepAliveProbe ( client_ , ct ) ) ;
368369 } catch ( Exception e ) {
369- // ignore. But I think we might want to throw?
370+ // ignore. But I think we might want to throw?
370371 Logger . Error ( "KeepAliveProbe failed with exception: " + e . Message ) ;
371372 }
372373 }
@@ -400,6 +401,11 @@ public static void AddExtraHeaders(HttpRequestMessage request)
400401 {
401402 // host & content-type header for signature verification, more headers here
402403 request . Headers . UserAgent . TryParseAdd ( USER_AGENT_HEADER ) ;
404+ // add extra headers
405+ foreach ( var item in extraHeaders )
406+ {
407+ request . Headers . Add ( item . Key , item . Value ) ;
408+ }
403409 }
404410
405411 private static bool httpClientVerifySSL = Connection . DEFAULT_VERIFY_SSL ;
@@ -434,6 +440,7 @@ protected internal static HttpClient GetHttpClient(
434440 public KGMSClient ( Connection conn ) : base ( KGMSClient . GetHttpClient ( conn . BaseUrl , conn . VerifySSL , conn . ConnectionTimeout ) )
435441 {
436442 this . conn = conn ;
443+ extraHeaders = conn . ExtraHeaders ;
437444 conn . Client = this ;
438445 this . BaseUrl = conn . BaseUrl . ToString ( ) ;
439446 }
@@ -479,23 +486,9 @@ public ActionResult RunAction(String name, Action action, out bool success, bool
479486 xact . Actions = new List < LabeledAction > ( ) ;
480487 xact . Actions . Add ( labeledAction ) ;
481488 xact . Readonly = isReadOnly ;
482- xact . Version = this . conn . Version ;
483489
484490 TransactionResult response = RunTransaction ( xact ) ;
485491
486- // Sync the reported database version to our local
487- // connection version. Important, as we want to ensure
488- // that in subsequent transactions this will be the
489- // minimum required version of the database. Note that
490- // only write transactions bump the version.
491- lock ( this . conn ) {
492- int currentVersion = conn . Version ;
493- int responseVersion = response . Version . GetValueOrDefault ( 0 ) ;
494- if ( responseVersion > currentVersion ) {
495- conn . Version = responseVersion ;
496- }
497- }
498-
499492 success = IsSuccess ( response ) ;
500493 foreach ( LabeledActionResult act in response . Actions )
501494 {
@@ -521,7 +514,6 @@ public bool CloneDatabase(string sourceDbname, bool overwrite = false)
521514 xact . Actions = new LinkedList < LabeledAction > ( ) ;
522515 xact . Source_dbname = sourceDbname ;
523516 xact . Readonly = false ;
524- xact . Version = this . conn . Version ;
525517 TransactionResult response = RunTransaction ( xact ) ;
526518
527519 if ( response . Problems . Count > 0 ) {
@@ -538,7 +530,6 @@ public bool CreateDatabase(bool overwrite = false)
538530 xact . Dbname = conn . DbName ;
539531 xact . Actions = new LinkedList < LabeledAction > ( ) ;
540532 xact . Readonly = false ;
541- xact . Version = this . conn . Version ;
542533
543534 TransactionResult response = RunTransaction ( xact ) ;
544535
0 commit comments