From 42c5672e5c5b521e71c1739ea59ebb9fb8175d3a Mon Sep 17 00:00:00 2001 From: mhilbrunner Date: Sat, 14 Apr 2018 16:39:38 +0200 Subject: [PATCH] HTTPRequest: Add HTTP header example, notes about SSL and embedded credentials --- tutorials/networking/http_request_class.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tutorials/networking/http_request_class.rst b/tutorials/networking/http_request_class.rst index fce7ca07..8964c248 100644 --- a/tutorials/networking/http_request_class.rst +++ b/tutorials/networking/http_request_class.rst @@ -42,3 +42,15 @@ With this, you should see ``(hello:world)`` printed on the console; hello being For more information on parsing JSON, see the class references for :ref:`JSON ` and :ref:`JSONParseResult `. Note that you may want to check whether the ``result`` equals ``RESULT_SUCCESS`` and whether a JSON parsing error occurred, see the JSON class reference and :ref:`HTTPRequest ` for more. + +Of course, you can also set custom HTTP headers. These are given as a string array, with each string containing a header in the format ``"header: value"``. +For example, to set a custom user agent (the HTTP ``user-agent`` header) you could use the following: + +:: + + $HTTPRequest.request("http://www.mocky.io/v2/5185415ba171ea3a00704eed", ["user-agent: YourCustomUserAgent"]) + +Please note that for SSL/TLS encryption and thus HTTPS URLs to work you may need to take some steps as described :ref:`here `. + +Also, when calling APIs using authorization, be aware that someone might analyse and decompile your released application and thus may gain access to any embedded authorization information like tokens, usernames or passwords. +That means it is usually not a good idea to embed things such as database access credentials inside your game. Avoid providing information useful to an attacker whenever possible.