This is a simple example that shows how to make a custom request using Ecore_Con_Url.
The full source code for this example can be found at ecore_con_url_headers_example.c.
The first part of the example is setting the callbacks to be called when an ECORE_CON_EVENT_URL_DATA or ECORE_CON_EVENT_URL_COMPLETE event is received. These are the callbacks that are going to be used with this:
The main
code is as simple as the Ecore_Con_Url example. It contains some checks for the arguments to see if a GET or POST request is required:
Then we start our required libraries and configure a global option to use pipelined requests:
Now we create our request object, but using ecore_con_url_custom_new() to use a POST or GET method depending on the command line arguments. And we also add the event handlers for our callbacks:
In order to demonstrate our API, some options are set to this request before actually performing it:
Depending on what kind of request was asked (GET or POST), we use one of the specific functions to perform it:
After that, we just check for errors, start the main loop, free resources and finally exit: