<commit_before><?xml version="1.0" encoding="UTF-8" ?>
<class name="HTTPRequest" inherits="Node" version="3.2">
	<brief_description>
		A node with the ability to send HTTP(S) requests.
	</brief_description>
	<description>
		A node with the ability to send HTTP requests. Uses [HTTPClient] internally.
		Can be used to make HTTP requests, i.e. download or upload files or web content via HTTP.
		[b]Example of contacting a REST API and printing one of its returned fields:[/b]
		[codeblock]
		func _ready():
		    # Create an HTTP request node and connect its completion signal.
		    var http_request = HTTPRequest.new()
		    add_child(http_request)
		    http_request.connect("request_completed", self, "_http_request_completed")

		    # Perform the HTTP request. The URL below returns some JSON as of writing.
		    var error = http_request.request("https://httpbin.org/get")
		    if error != OK:
		        push_error("An error occurred in the HTTP request.")


		# Called when the HTTP request is completed.
		func _http_request_completed(result, response_code, headers, body):
		    var response = parse_json(body.get_string_from_utf8())

		    # Will print the user agent string used by the HTTPRequest node (as recognized by httpbin.org).
		    print(response.headers["User-Agent"])
		[/codeblock]
		[b]Example of loading and displaying an image using HTTPRequest:[/b]
		[codeblock]
		func _ready():
		    # Create an HTTP request node and connect its completion signal.
		    var http_request = HTTPRequest.new()
		    add_child(http_request)
		    http_request.connect("request_completed", self, "_http_request_completed")

		    # Perform the HTTP request. The URL below returns a PNG image as of writing.
		    var error = http_request.request("https://via.placeholder.com/512")<commit_msg>Add a POST request example to the HTTPRequest class documentation<commit_after><?xml version="1.0" encoding="UTF-8" ?>
<class name="HTTPRequest" inherits="Node" version="3.2">
	<brief_description>
		A node with the ability to send HTTP(S) requests.
	</brief_description>
	<description>
		A node with the ability to send HTTP requests. Uses [HTTPClient] internally.
		Can be used to make HTTP requests, i.e. download or upload files or web content via HTTP.
		[b]Example of contacting a REST API and printing one of its returned fields:[/b]
		[codeblock]
		func _ready():
		    # Create an HTTP request node and connect its completion signal.
		    var http_request = HTTPRequest.new()
		    add_child(http_request)
		    http_request.connect("request_completed", self, "_http_request_completed")

		    # Perform a GET request. The URL below returns JSON as of writing.
		    var error = http_request.request("https://httpbin.org/get")
		    if error != OK:
		        push_error("An error occurred in the HTTP request.")

		    # Perform a POST request. The URL below returns JSON as of writing.
		    # Note: Don't make simultaneous requests using a single HTTPRequest node.
		    # The snippet below is provided for reference only.
		    var body = {"name": "Godette"}
		    var error = http_request.request("https://httpbin.org/post", [], true, HTTPClient.METHOD_POST, body)
		    if error != OK:
		        push_error("An error occurred in the HTTP request.")


		# Called when the HTTP request is completed.
		func _http_request_completed(result, response_code, headers, body):
		    var response = parse_json(body.get_string_from_utf8())

		    # Will print the user agent string used by the HTTPRequest node (as recognized by httpbin.org).
		    print(response.headers["User-Agent"])
		[/codeblock]
		[b]Example of loading and displaying an image using HTTPRequest:[/b]
		[codeblock]
		func _ready():
		    # Create an HTTP request node and connect its completion signal.
		    var http_request = HTTPRequest.new()
		    add_child(http_request)
		    http_request.connect("request_completed", self, "_http_request_completed")

		    # Perform the HTTP request. The URL below returns a PNG image as of writing.
		    var error = http_request.request("https://via.placeholder.com/512")
{'fraction_non_alphanumeric': 0.0926197458455523, 'fraction_numerical': 0.004398826979472141, 'mean_word_length': 3.672374429223744, 'pattern_counts': {'":': 1, '<': 13, '<?xml version=': 2, '>': 13, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1046808', 'n_tokens_mistral': 1260, 'n_tokens_neox': 1109, 'n_words': 427}