HTTP Request
Qubes 6.1 Retrieves data via an HTTP query.
Properties
| Property | Description |
| Content | Specify the content when the HTTP method supports a content (Qubes 9.0) |
| Enabled | Boolean indicating whether or not the component is enabled. |
| Headers | Allows specifying custom HTTP headers (Qubes 7.2) |
| Hint | Specifies the user hint string that will appear in the component's interactive help bubble. |
| Method | Specify the HTTP method to use (can be GET or POST, with GET the default value, Qubes 9.0) |
| ValueInitial | Determines the component's initial value when the screen opens and each time it is reset (see Reset Button). |
| Visible | Boolean indicating whether or not the component will be visible. |
| TempState | Indicates whether or not the state is temporary (Qubes 6.2). |
| Trigger | Controls how queries are triggered (auto by default) (Qubes 6.2). |
| URL | URL to query. |
Value
The component's value is a string corresponding to the data retrieved from the URL.
- During the time of the query, the value will be #TMP! if TempState is True.
- If the query fails, the value will be #ERR!.
If the TempState property is False, the value will be the result of the query, or #ERR!.
Remarks
Trigger controls how a query is triggered, independent of any changes to the URL. By default (auto), a new query will run every time the value of the URL property changes. If Trigger is anything other than "auto," a new query will be triggered every time the value of the Trigger property changes.
Headers, when specified, should be a list of HTTP header name and HTTP header value.
Dynamic Enabled property is supported in Qubes 9.0, it will prevent new requests from being sent, but will not abort a previously started request.
Cross-Origin Resource Sharing considerations
The component will run an asynchronous query in the browser. If the API URL is not on the same domain (or more broadly same origin), it will be subject to same-origin policy restrictions. If supported by the browser (all except Internet Explorer 9 and lower), a query will be run using cross-origin resource sharing.
For the CORS query to be accepted, the server on which the URL is called will need to allow it. In the case of a Qubes web process, an "Allow CORS" option can be enabled in that web process to allow access from everywhere. In a larger company Intranet or on the Internet, it is highly recommended to read on CORS and fine-tune the CORS headers (WebResponse.Header can be used to specify the header).
POST requests
In Qubes 9.0 the Method and Content properties can be used to perform a POST request:
- GET: the value of Content is ignored
- POST: the value of Content is interpreted as follows
* if a value is passed, it will be converted to string and stringified * if a list is passed, then the first element is the data, the second is the type.
If the type is 'json' then the data will be posted directly, otherwise, it will be converted to string and stringified * the POST content-type is always 'application/json'
Note that when passing 'json', you have to provided a correct JSON string, or the request will either send no data or send invalid content.