JSHTTPRequest API.
More...
import"httpout.idl";
|
attribute void | send () |
|
attribute DOMString body attribute signed long | throttle (unsigned long long done, unsigned long long total) |
|
attribute signed long | read (ArrayBuffer buffer) |
|
attribute void | write (ArrayBuffer buffer) |
|
attribute void | close (unsigned long error) |
|
The JSHTTPRequest object provides an interface to the HTTP request being processed.
◆ send()
attribute void JSHTTPRequest::send |
( |
| ) |
|
send the response to the request
◆ throttle()
attribute DOMString body attribute signed long JSHTTPRequest::throttle |
( |
unsigned long long |
done, |
|
|
unsigned long long |
total |
|
) |
| |
reply body. It is undefined by default
- if reply is 0, this can be set to a file path to serve. If not set, usual URL resolving of httpout is done
- if reply is not 0, this can be set to a string containing the body. To deliver a binary file or a large file, use the read function
callback function used to throttle the download, can be used even if the request is handled by gpac. It is set to null by default
- Parameters
-
done | amount of bytes already sent in request |
total | total amount of bytes in request |
- Returns
- a delay for next send in milliseconds
◆ read()
attribute signed long JSHTTPRequest::read |
( |
ArrayBuffer |
buffer | ) |
|
callback function used to get data (GET requests). It is set to null by default
- Parameters
-
buffer | array buffer to fill (shared array, do NOT keep) |
- Returns
- the number of bytes read, negative value means no data available yet, 0 means end of file
◆ write()
attribute void JSHTTPRequest::write |
( |
ArrayBuffer |
buffer | ) |
|
callback function used to receive data (PUT/POST requests). It is set to null by default
- Parameters
-
buffer | array buffer received. If null, end of stream is reached |
◆ close()
attribute void JSHTTPRequest::close |
( |
unsigned long |
error | ) |
|
callback function used to monitor end of session. It is set to null by default
- Parameters
-
error | GPAC error code for the session. If 1 (GF_EOS), the session is ended but underlying network is kept alive, otherwise session is destroyed |
◆ reply
attribute unsigned long JSHTTPRequest::reply |
HTTP reply code to use. If 0, the request is handled by GPAC as usual. Otherwise, the request is handled by your script if the reply does not indicate an error
◆ method
attribute readonly DOMString JSHTTPRequest::method |
HTTP method of the request
◆ url
attribute readonly DOMString JSHTTPRequest::url |
◆ auth_code
attribute readonly unsigned long JSHTTPRequest::auth_code |
Authentication reply code - requests are pre-identified using GPAC credentials: a value of 401 indicates no identification, 200 indicates identification OK, 403 indicates failure
◆ headers_in
attribute readonly Array JSHTTPRequest::headers_in |
◆ headers_out
attribute Array JSHTTPRequest::headers_out |
HTTP headers to set on the response, array of JSHTTPHeader objects (initialized as empty)