Some checks failed
Build and Deploy / build-linux (push) Failing after 1m3s
Build and Deploy / build-windows (CLANG64) (push) Successful in 9m45s
Build and Deploy / package-dist (push) Has been skipped
Build and Deploy / deploy-itch (push) Has been skipped
Build and Deploy / deploy-gitea (push) Has been skipped
27 lines
1.6 KiB
JavaScript
27 lines
1.6 KiB
JavaScript
var http = this
|
|
|
|
http.fetch[prosperon.DOC] = `Initiate an asynchronous HTTP GET request.
|
|
|
|
This function enqueues an HTTP GET request for the specified URL. It supports both buffered responses (full response collected in memory) and streaming data (processed as it arrives). The request is executed asynchronously, and its completion or streaming data is handled via callbacks provided in the options. Use 'poll' to process the results.
|
|
|
|
:param url: A string representing the URL to fetch.
|
|
:param options: Either a callback function or an object with optional properties:
|
|
- 'callback': A function invoked upon request completion, receiving an object with 'data' (string or null) and 'error' (string or null) properties.
|
|
- 'on_data': A function invoked for each chunk of streaming data, receiving a string chunk as its argument. If supplied, 'callback.data' will be null.
|
|
:return: undefined
|
|
:throws:
|
|
- An error if the URL is not a string or is invalid.
|
|
- An error if the options argument is neither a function nor an object.
|
|
- An error if memory allocation or CURL initialization fails.
|
|
`
|
|
|
|
http.poll[prosperon.DOC] = `Process pending HTTP requests and invoke callbacks.
|
|
|
|
This function checks for I/O activity on all enqueued HTTP requests and processes any that have completed or received data. For completed requests, it invokes the 'callback' function (if provided) with the result. For streaming requests, it invokes the 'data' function (if provided) as data arrives. This function must be called repeatedly to drive the asynchronous request system.
|
|
|
|
:return: undefined
|
|
:throws: An error if CURL multi-handle processing fails.
|
|
`
|
|
|
|
return http
|