HttpRequestBuilder
Object Hierarchy:
Description:
public class HttpRequestBuilder : Object
Builder for constructing HTTP requests with custom settings.
Example:
var resp = Http.request ("POST", "http://localhost:8080/data")
.header ("Authorization", "Bearer token123")
.body ("payload")
.timeoutMillis (5000)
.send ();
Content:
Methods:
- public HttpRequestBuilder basicAuth (string user, string password)
Sets Basic Authentication header.
- public HttpRequestBuilder bearerToken (string token)
Sets Bearer token authentication header.
- public HttpRequestBuilder body (string text)
Sets the request body as a string.
- public HttpRequestBuilder bytes (uint8[] bytes)
Sets the request body to raw bytes.
- public HttpRequestBuilder followRedirects (bool follow)
Enables or disables redirect following.
- public HttpRequestBuilder formData (HashMap<string,string> fields)
Sets the request body to URL-encoded form data.
- public HttpRequestBuilder header (string name, string value)
Adds a request header.
- public HttpRequestBuilder headers (HashMap<string,string> map)
Adds multiple request headers at once.
- public HttpRequestBuilder json (JsonValue value)
Sets the request body to JSON text.
- public HttpRequestBuilder query (string key, string value)
Adds a query parameter to the URL.
- public HttpResponse? send ()
Sends the constructed request and returns the response.
- public HttpRequestBuilder timeoutMillis (int ms)
Sets the request timeout in milliseconds.
Inherited Members:
All known members inherited from class GLib.Object
- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data
- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer
- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref