HTTPSSEClient
HTTPSSEClient copied to clipboard
Support making an arbitrary HTTP request that returns an event stream
It would be nice if the plugin can support making an arbitrary HTTP request which returns an event stream response instead of just making a GET request to / in the attempt_to_request() method.
Example:
POST https://api.openai.com/v1/chat/completions
with headers
[
"Content-Type: application/json",
"Authorization: Bearer <token here>"
]
with body
{
"stream": true,
"messages": [{"role": "user", "content": "what is godot engine"}],
"model": "gpt-4o-mini"
}
Proposed api:
func request(url: String, custom_headers = [], method = HTTPClient.METHOD_GET, body = ""): Error
func request_raw(url: String, custom_headers = [], method = HTTPClient.METHOD_GET, body_raw =PackedByteArray()): Error
Example usage:
var sse = HTTPSSEClient.new()
sse.new_sse_event.connect(_on_new_sse_event)
var err = sse.request(...)
if err != OK:
printerr("Failed to send request error=%s" % err)