partial void PrepareRequest(Transaction body, HttpClient client, HttpRequestMessage request, string url) { var uriBuilder = new UriBuilder(request.RequestUri); var query = HttpUtility.ParseQueryString(uriBuilder.Query); if (conn is LocalConnection) { query["dbname"] = conn.DbName; if (!_isEmpty(body.Source_dbname)) { query["source_dbname"] = body.Source_dbname; } } query["open_mode"] = body.Mode.ToString(); if (conn is ManagementConnection || conn is CloudConnection) { query["region"] = EnumString.GetDescription(conn.Region); } if (conn is CloudConnection) { query["compute_name"] = conn.ComputeName; } uriBuilder.Query = query.ToString(); request.RequestUri = uriBuilder.Uri; // populate headers request.Headers.Host = request.RequestUri.Host; request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); // sign request here var raiRequest = new RAIRequest(request, conn); raiRequest.Sign(debugLevel: DebugLevel); DelveClient.AddExtraHeaders(request); // use HTTP 2.0 (to handle keep-alive) request.Version = System.Net.HttpVersion.Version20; // have a separate keep-alive task (per thread) if (!isStatusRequest(body)) { var tokenSource = new CancellationTokenSource(); AsyncLocalKeepAliveCancellationTokenSource.Value = tokenSource; CancellationToken ct = tokenSource.Token; /** * TODO: currently we swallo exceptions in KeepClientAlive. * If we want to throw, then we need to change this to asynchronously handle the throw * e.g. * try { * await this.KeepClientAlive(client, url, ct).ConfigureAwait(false); * } catch (Exception e) { * // Handle here * } **/ var keep_alive_task = this.KeepClientAlive(client, url, ct).ConfigureAwait(false); } }
partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url) { if (request.Content == null) { request.Content = new StringContent(""); } // populate headers request.Headers.Clear(); request.Content.Headers.Clear(); request.Headers.Host = request.RequestUri.Host; request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); RAIRequest raiReq = new RAIRequest(request, conn); raiReq.Sign(); DelveClient.AddExtraHeaders(request); }
public DelveCloudClient(Connection conn) : base(DelveClient.GetHttpClient(conn.BaseUrl, conn.VerifySSL, conn.ConnectionTimeout)) { this.conn = conn; this.conn.CloudClient = this; this.BaseUrl = conn.BaseUrl.ToString(); }
public GeneratedDelveClient(Connection conn) { this.conn = conn; _httpClient = DelveClient.GetHttpClient(conn.BaseUrl, conn.VerifySSL, conn.ConnectionTimeout); _settings = new System.Lazy <Newtonsoft.Json.JsonSerializerSettings>(CreateSerializerSettings); }