From e829b7aee48cfc988abea5a42bdbf02638a16513 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Sun, 29 Nov 2020 22:43:38 -0500 Subject: Unify URI encoding/decoding and add to C# http_escape and percent_encode have been unified into uri_encode, and http_unescape and percent_decode have been unified into uri_decode. --- doc/classes/HTTPClient.xml | 2 +- doc/classes/HTTPRequest.xml | 2 +- doc/classes/String.xml | 64 +++++++++++++++++++++------------------------ 3 files changed, 32 insertions(+), 36 deletions(-) (limited to 'doc') diff --git a/doc/classes/HTTPClient.xml b/doc/classes/HTTPClient.xml index b6594aac39..9ff682f79d 100644 --- a/doc/classes/HTTPClient.xml +++ b/doc/classes/HTTPClient.xml @@ -175,7 +175,7 @@ var result = new HTTPClient().Request(HTTPClient.Method.Post, "index.php", headers, queryString); [/csharp] [/codeblocks] - [b]Note:[/b] The [code]request_data[/code] parameter is ignored if [code]method[/code] is [constant HTTPClient.METHOD_GET]. This is because GET methods can't contain request data. As a workaround, you can pass request data as a query string in the URL. See [method String.http_escape] for an example. + [b]Note:[/b] The [code]request_data[/code] parameter is ignored if [code]method[/code] is [constant HTTPClient.METHOD_GET]. This is because GET methods can't contain request data. As a workaround, you can pass request data as a query string in the URL. See [method String.uri_encode] for an example. diff --git a/doc/classes/HTTPRequest.xml b/doc/classes/HTTPRequest.xml index f2ab93033a..a65f66c72a 100644 --- a/doc/classes/HTTPRequest.xml +++ b/doc/classes/HTTPRequest.xml @@ -203,7 +203,7 @@ Creates request on the underlying [HTTPClient]. If there is no configuration errors, it tries to connect using [method HTTPClient.connect_to_host] and passes parameters onto [method HTTPClient.request]. Returns [constant OK] if request is successfully created. (Does not imply that the server has responded), [constant ERR_UNCONFIGURED] if not in the tree, [constant ERR_BUSY] if still processing previous request, [constant ERR_INVALID_PARAMETER] if given string is not a valid URL format, or [constant ERR_CANT_CONNECT] if not using thread and the [HTTPClient] cannot connect to host. - [b]Note:[/b] The [code]request_data[/code] parameter is ignored if [code]method[/code] is [constant HTTPClient.METHOD_GET]. This is because GET methods can't contain request data. As a workaround, you can pass request data as a query string in the URL. See [method String.http_escape] for an example. + [b]Note:[/b] The [code]request_data[/code] parameter is ignored if [code]method[/code] is [constant HTTPClient.METHOD_GET]. This is because GET methods can't contain request data. As a workaround, you can pass request data as a query string in the URL. See [method String.uri_encode] for an example. diff --git a/doc/classes/String.xml b/doc/classes/String.xml index 1de4e41cf8..c03f6357ab 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -244,26 +244,6 @@ [/codeblocks] - - - - - Escapes (encodes) a string to URL friendly format. Also referred to as 'URL encode'. - [codeblock] - print("https://example.org/?escaped=" + "Godot Engine:'docs'".http_escape()) - [/codeblock] - - - - - - - Unescapes (decodes) a string in URL encoded format. Also referred to as 'URL decode'. - [codeblock] - print("https://example.org/?escaped=" + "Godot%20Engine%3A%27docs%27".http_unescape()) - [/codeblock] - - @@ -578,20 +558,6 @@ Formats a number to have an exact number of [code]digits[/code] before the decimal point. - - - - - Decode a percent-encoded string. See [method percent_encode]. - - - - - - - Percent-encodes a string. Encodes parameters in a URL when sending a HTTP GET request (and bodies of form-urlencoded POST requests). - - @@ -891,6 +857,36 @@ Returns the character code at position [code]at[/code]. + + + + + Decodes a string in URL encoded format. This is meant to decode parameters in a URL when receiving an HTTP request. + [codeblocks] + [gdscript] + print("https://example.org/?escaped=" + "Godot%20Engine%3A%27docs%27".uri_decode()) + [/gdscript] + [csharp] + GD.Print("https://example.org/?escaped=" + "Godot%20Engine%3a%27Docs%27".URIDecode()); + [/csharp] + [/codeblocks] + + + + + + + Encodes a string to URL friendly format. This is meant to encode parameters in a URL when sending an HTTP request. + [codeblocks] + [gdscript] + print("https://example.org/?escaped=" + "Godot Engine:'docs'".uri_encode()) + [/gdscript] + [csharp] + GD.Print("https://example.org/?escaped=" + "Godot Engine:'docs'".URIEncode()); + [/csharp] + [/codeblocks] + + -- cgit v1.2.3