HTTPClient remains as connected and STATUS_BODY if using event-stream…
Created by: volzhs
… header
faced this issue while working on streaming from the REST API https://firebase.google.com/docs/reference/rest/database/#section-streaming
extends Node2D
var client:HTTPClient
func _ready():
client = HTTPClient.new()
client.connect_to_host( "godotfirebasetest.firebaseio.com", -1, true, true )
pass
var req_once = false
func _process(delta):
if client != null:
var poll = client.poll()
if client.get_status() == HTTPClient.STATUS_CONNECTED and !req_once:
var url = "/test.json"
client.request(HTTPClient.METHOD_GET, url, ["Accept: text/event-stream"], "")
req_once = true
elif client.get_status() == HTTPClient.STATUS_BODY:
var body = client.read_response_body_chunk()
if body.size() > 0:
print("get body\n", body.get_string_from_utf8())