ProxyCall
Object Hierarchy:
Description:
[ CCode ( type_id = "rest_proxy_call_get_type ()" ) ]
public class ProxyCall : Object
ProxyCall has no publicly available members.
Example: Read raw data, async:
public static int main (string[] args) {
try {
MainLoop loop = new MainLoop ();
Rest.Proxy proxy = new Rest.Proxy ("http://www.flickr.com/services/rest/", false);
Rest.ProxyCall call = proxy.new_call ();
call.add_params (
"method", "flickr.test.echo",
"api_key", "314691be2e63a4d58994b2be01faacfb",
"format", "json"
);
call.run_async ((call, error, obj) => {
string payload = call.get_payload ();
int64 len = call.get_payload_length ();
// We interpret the result as data:
unowned uint8[] arr = (uint8[]) payload;
arr.length = (int) len;
stdout.write (arr, sizeof (uint8));
loop.quit ();
}, null);
loop.run ();
} catch (Error e) {
stderr.puts (e.message);
stderr.putc ('\n');
}
return 0;
}
valac --pkg rest-0.7 test-raw-async.vala
Example: Read raw data, sync:
public static int main (string[] args) {
MainLoop loop = new MainLoop ();
try {
Rest.Proxy proxy = new Rest.Proxy ("http://www.flickr.com/services/rest/", false);
Rest.ProxyCall call = proxy.new_call ();
call.add_params (
"method", "flickr.test.echo",
"api_key", "314691be2e63a4d58994b2be01faacfb",
"format", "json"
);
call.run ();
string payload = call.get_payload ();
int64 len = call.get_payload_length ();
// We interpret the result as data:
unowned uint8[] arr = (uint8[]) payload;
arr.length = (int) len;
stdout.write (arr, sizeof (uint8));
} catch (Error e) {
stderr.puts (e.message);
stderr.putc ('\n');
}
loop = null;
return 0;
}
valac --pkg rest-0.7 test-raw-sync.vala
Content:
Properties:
Creation methods:
Methods:
- public void add_header (string header, string value)
Add a header called header
with the value value
to the call.
- public void add_headers (...)
Add the specified header name and value pairs to the call.
- public void add_param (string name, string value)
Add a query parameter called param
with the string value
value
to the call.
- public void add_param_full (owned Param param)
- public void add_params (...)
Add the specified parameter name and value pairs to the call.
- public bool cancel ()
Cancel this call.
- public bool continuous (ProxyCallContinuousCallback callback, Object weak_object) throws Error
Asynchronously invoke this but
expect a continuous stream of content.
- public unowned string get_function ()
Get the REST function that is going to be called on the proxy.
- public unowned string get_method ()
Get the HTTP method to use when making the call, for example GET or
POST.
- public unowned Params get_params ()
Get the parameters as a
Params of parameter names to values.
- public unowned string get_payload ()
Get the return payload.
- public int64 get_payload_length ()
Get the length of the return payload.
- public HashTable<unowned string,unowned string> get_response_headers ()
- public uint get_status_code ()
Get the HTTP status code for the call.
- public unowned string get_status_message ()
Get the human-readable HTTP status message for the call.
- public async bool invoke_async (Cancellable? cancellable) throws Error
- public unowned string lookup_header (string header)
Get the value of the header called header
.
- public Param lookup_param (string name)
Get the value of the parameter called name
.
- public unowned string lookup_response_header (string header)
Get the string value of the header header
or null
if that header is not present or there are no headers.
- public virtual bool prepare () throws Error
- public void remove_header (string header)
Remove the header named header
from the call.
- public void remove_param (string name)
Remove the parameter named name
from the call.
- public bool run (out unowned MainLoop loop = null) throws Error
- public bool run_async (ProxyCallAsyncCallback callback, Object? weak_object = null) throws Error
Asynchronously invoke this.
- public virtual bool serialize_params (out string content_type, out string content, out size_t content_len) throws Error
Invoker for a virtual method to serialize the parameters for this
ProxyCall.
- public void set_function (string function)
Set the REST "function" to call on the proxy.
- public void set_method (string method)
Set the HTTP method to use when making the call, for example GET or
POST.
- public bool sync () throws Error
- public bool upload (ProxyCallUploadCallback callback, Object weak_object) throws Error
Asynchronously invoke this but
expect to have the callback invoked every time a chunk of our request's body is written.
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