@@ -22,7 +22,7 @@ public partial class GeneratedRelationalAIClient
2222
2323 public const string JSON_CONTENT_TYPE = "application/json" ;
2424 public const string CSV_CONTENT_TYPE = "text/csv" ;
25- public const string USER_AGENT_HEADER = "KGMSClient/1.2.1 /csharp" ;
25+ public const string USER_AGENT_HEADER = "KGMSClient/1.2.2 /csharp" ;
2626
2727 public int DebugLevel = Connection . DEFAULT_DEBUG_LEVEL ;
2828
@@ -53,14 +53,25 @@ partial void PrepareRequest(Transaction body, HttpClient client, HttpRequestMess
5353 }
5454 if ( conn is CloudConnection ) {
5555 query [ "compute_name" ] = conn . ComputeName ;
56+ // Note:
57+ // We need to send the gzip content encoding header and a gzip compressed body only in case of a CloudConnection.
58+ // Local rai-server cannot handle gzip encoding, only infra server support does.
59+
60+ // Compress the contents (request body) as gzipped byte array. C# httpclient does not implicitly compress the content over the wire
61+ // if content encoding is gzip; we need to manually compress the body.
62+ // 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.
63+ request . Content = CompressionUtils . CompressRequestContentAsGzip ( request . Content ) ;
64+ //Set the content encoding type header as gzip. It will tell the server that the content is gzip encoded.
65+ request . Content . Headers . Add ( "content-encoding" , "gzip" ) ;
5666 }
5767 uriBuilder . Query = query . ToString ( ) ;
5868 request . RequestUri = uriBuilder . Uri ;
5969
6070 // populate headers
6171 request . Headers . Host = request . RequestUri . Host ;
72+ //Set the content type header
6273 request . Content . Headers . ContentType = MediaTypeHeaderValue . Parse ( "application/json; charset=utf-8" ) ;
63-
74+
6475 // sign request here
6576 var raiRequest = new RAIRequest ( request , conn ) ;
6677 raiRequest . Sign ( debugLevel : DebugLevel ) ;
0 commit comments