Top |
Functions
RestParam * | rest_param_new_string () |
RestParam * | rest_param_new_full () |
RestParam * | rest_param_new_with_owner () |
gboolean | rest_param_is_string () |
const char * | rest_param_get_name () |
const char * | rest_param_get_content_type () |
const char * | rest_param_get_file_name () |
gconstpointer | rest_param_get_content () |
gsize | rest_param_get_content_length () |
RestParam * | rest_param_ref () |
void | rest_param_unref () |
Functions
rest_param_new_string ()
RestParam * rest_param_new_string (const char *name
,RestMemoryUse use
,const char *string
);
A convience constructor to create a RestParam from a given UTF-8 string. The resulting RestParam will have a content type of "text/plain".
Parameters
name |
the parameter name |
|
use |
the RestMemoryUse describing how the memory can be used |
|
string |
the parameter value |
rest_param_new_full ()
RestParam * rest_param_new_full (const char *name
,RestMemoryUse use
,gconstpointer data
,gsize length
,const char *content_type
,const char *filename
);
Create a new RestParam called name
with length
bytes of data
as the
value. content_type
is the type of the data as a MIME type, for example
"text/plain" for simple string parameters.
If the parameter is a file upload it can be passed as filename
.
Parameters
name |
the parameter name |
|
use |
the RestMemoryUse describing how the memory can be used |
|
data |
a pointer to the start of the data. |
[array length=length][element-type guint8] |
length |
the length of the data |
|
content_type |
the content type of the data |
|
filename |
the original filename, or |
rest_param_new_with_owner ()
RestParam * rest_param_new_with_owner (const char *name
,gconstpointer data
,gsize length
,const char *content_type
,const char *filename
,gpointer owner
,GDestroyNotify owner_dnotify
);
Create a new RestParam called name
with length
bytes of data
as the
value. content_type
is the type of the data as a MIME type, for example
"text/plain" for simple string parameters.
If the parameter is a file upload it can be passed as filename
.
When the RestParam is freed, it will call owner_dnotify
, passing owner
to
it. This allows you to do something like this:
1 2 3 4 5 6 7 8 |
GMappedFile *map = g_mapped_file_new (filename, FALSE, &error); RestParam *param = rest_param_new_with_owner ("media", g_mapped_file_get_contents (map), g_mapped_file_get_length (map), "image/jpeg", filename, map, (GDestroyNotify)g_mapped_file_unref); |
Parameters
name |
the parameter name |
|
data |
a pointer to the start of the data. |
[array length=length][element-type guint8] |
length |
the length of the data |
|
content_type |
the content type of the data |
|
filename |
the original filename, or |
[allow-none] |
owner |
pointer to an object that owns |
[transfer full] |
owner_dnotify |
a function to free/unref |
[allow-none] |
rest_param_is_string ()
gboolean
rest_param_is_string (RestParam *param
);
Determine if the parameter is a string value, i.e. the content type is "text/plain".
rest_param_get_name ()
const char *
rest_param_get_name (RestParam *param
);
Get the name of the parameter.
rest_param_get_content_type ()
const char *
rest_param_get_content_type (RestParam *param
);
Get the MIME type of the parameter. For example, basic strings have the MIME type "text/plain".
rest_param_get_file_name ()
const char *
rest_param_get_file_name (RestParam *param
);
Get the original file name of the parameter, if one is available.
rest_param_get_content ()
gconstpointer
rest_param_get_content (RestParam *param
);
Get the content of param
. The content should be treated as read-only and
not modified in any way.
rest_param_get_content_length ()
gsize
rest_param_get_content_length (RestParam *param
);
Get the length of the content of param
.
rest_param_ref ()
RestParam *
rest_param_ref (RestParam *param
);
Increase the reference count on param
.