From 0b4be9a094de2bb38f2322191079f8e06655e9c0 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Sun, 29 Oct 2023 01:54:17 +0100 Subject: [PATCH 1/2] Fixed markdown links (brackets=>parentheses). Signed-off-by: Konstantina Chremmou --- ocaml/sdk-gen/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ocaml/sdk-gen/README.md b/ocaml/sdk-gen/README.md index 5185a9cd71f..7473d141f83 100644 --- a/ocaml/sdk-gen/README.md +++ b/ocaml/sdk-gen/README.md @@ -9,7 +9,7 @@ XenAPI's datamodel. The generation code is written in OCaml and is contained in this directory. The Python module is not auto-generated, it can be found at -[XenAPI.py][../../scripts/examples/python/XenAPI/XenAPI.py]. +[XenAPI.py](../../scripts/examples/python/XenAPI/XenAPI.py). To compile the generated source code, follow the instructions in the corresponding README files. The (patched) third party libraries required for the compilation @@ -23,7 +23,7 @@ you get started with the SDK. ## Licensing The SDK generation code is licensed under the GNU LGPLv2 license. Please see this -[LICENSE][../../LICENSE] file for more information. +[LICENSE](../../LICENSE) file for more information. The generated code and the examples are licensed under the BSD 2-Clause license. -Please see this [LICENSE][LICENSE] file for more information. +Please see this [LICENSE](LICENSE) file for more information. From 0c00825c7231438bb9d922e40e13d8fd16fe8fb8 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Fri, 15 Dec 2023 20:56:35 +0000 Subject: [PATCH 2/2] Allow passing extra headers into the HTTP calls (useful for CP-33676). Renamed a couple of local parameters. Signed-off-by: Konstantina Chremmou --- ocaml/sdk-gen/csharp/autogen/src/HTTP.cs | 65 +++++++++++++++++------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/ocaml/sdk-gen/csharp/autogen/src/HTTP.cs b/ocaml/sdk-gen/csharp/autogen/src/HTTP.cs index 4e6bf40a3da..60fe64f4de5 100644 --- a/ocaml/sdk-gen/csharp/autogen/src/HTTP.cs +++ b/ocaml/sdk-gen/csharp/autogen/src/HTTP.cs @@ -668,9 +668,9 @@ private static void AuthenticateProxy(ref Stream stream, Uri uri, IWebProxy prox } - private static Stream DoHttp(Uri uri, IWebProxy proxy, bool nodelay, int timeout_ms, params string[] headers) + private static Stream DoHttp(Uri uri, IWebProxy proxy, bool noDelay, int timeoutMs, params string[] headers) { - Stream stream = ConnectStream(uri, proxy, nodelay, timeout_ms); + Stream stream = ConnectStream(uri, proxy, noDelay, timeoutMs); int redirects = 0; @@ -687,7 +687,7 @@ private static Stream DoHttp(Uri uri, IWebProxy proxy, bool nodelay, int timeout stream.Flush(); } - while (ReadHttpHeaders(ref stream, proxy, nodelay, timeout_ms)); + while (ReadHttpHeaders(ref stream, proxy, noDelay, timeoutMs)); return stream; } @@ -695,35 +695,64 @@ private static Stream DoHttp(Uri uri, IWebProxy proxy, bool nodelay, int timeout /// /// Adds HTTP CONNECT headers returning the stream ready for use /// - public static Stream HttpConnectStream(Uri uri, IWebProxy proxy, String session, int timeoutMs) + public static Stream HttpConnectStream(Uri uri, IWebProxy proxy, string session, int timeoutMs, Dictionary additionalHeaders = null) { - return DoHttp(uri, proxy, true, timeoutMs, - string.Format("CONNECT {0} HTTP/1.0", uri.PathAndQuery), - string.Format("Host: {0}", uri.Host), - string.Format("Cookie: session_id={0}", session)); + var allHeaders = new List + { + $"CONNECT {uri.PathAndQuery} HTTP/1.0", + $"Host: {uri.Host}", + $"Cookie: session_id={session}" + }; + + if (additionalHeaders != null) + { + foreach (var kvp in additionalHeaders) + allHeaders.Add($"{kvp.Key}: {kvp.Value}"); + } + + return DoHttp(uri, proxy, true, timeoutMs, allHeaders.ToArray()); } /// /// Adds HTTP PUT headers returning the stream ready for use /// - public static Stream HttpPutStream(Uri uri, IWebProxy proxy, long contentLength, int timeoutMs) + public static Stream HttpPutStream(Uri uri, IWebProxy proxy, long contentLength, int timeoutMs, Dictionary additionalHeaders = null) { - return DoHttp(uri, proxy, false, timeoutMs, - string.Format("PUT {0} HTTP/1.0", uri.PathAndQuery), - string.Format("Host: {0}", uri.Host), - string.Format("Content-Length: {0}", contentLength)); + var allHeaders = new List + { + $"PUT {uri.PathAndQuery} HTTP/1.0", + $"Host: {uri.Host}", + $"Content-Length: {contentLength}" + }; + + if (additionalHeaders != null) + { + foreach (var kvp in additionalHeaders) + allHeaders.Add($"{kvp.Key}: {kvp.Value}"); + } + + return DoHttp(uri, proxy, false, timeoutMs, allHeaders.ToArray()); } /// /// Adds HTTP GET headers returning the stream ready for use /// - public static Stream HttpGetStream(Uri uri, IWebProxy proxy, int timeoutMs) + public static Stream HttpGetStream(Uri uri, IWebProxy proxy, int timeoutMs, Dictionary additionalHeaders = null) { - return DoHttp(uri, proxy, false, timeoutMs, - string.Format("GET {0} HTTP/1.0", uri.PathAndQuery), - string.Format("Host: {0}", uri.Host)); - } + var allHeaders = new List + { + $"GET {uri.PathAndQuery} HTTP/1.0", + $"Host: {uri.Host}" + }; + if (additionalHeaders != null) + { + foreach (var kvp in additionalHeaders) + allHeaders.Add($"{kvp.Key}: {kvp.Value}"); + } + + return DoHttp(uri, proxy, false, timeoutMs, allHeaders.ToArray()); + } /// /// A general HTTP PUT method, with delegates for progress and cancelling. May throw various exceptions.