12 #define COOKIEJAR "cookies.jar"
15 _url_data_cb(void *data __UNUSED__, int type __UNUSED__, void *event_info)
17 Ecore_Con_Event_Url_Data *url_data = event_info;
20 printf("\nData received from server:\n>>>>>\n");
21 for (i = 0; i < url_data->size; i++)
22 printf("%c", url_data->data[i]);
23 printf("\n>>>>>>\n\n");
29 _url_complete_cb(void *data __UNUSED__, int type __UNUSED__, void *event_info)
31 Ecore_Con_Event_Url_Complete *url_complete = event_info;
32 const Eina_List *headers, *l;
36 printf("download completed with status code: %d\n", url_complete->status);
38 headers = ecore_con_url_response_headers_get(url_complete->url_con);
40 printf("response headers:\n");
41 EINA_LIST_FOREACH(headers, l, str)
42 printf("header: %s", str);
44 ecore_con_url_cookies_jar_write(url_complete->url_con);
46 ecore_main_loop_quit();
52 main(int argc, const char *argv[])
54 Ecore_Con_Url *ec_url = NULL;
60 printf("need at least one parameter: <url> [command]\n");
71 ec_url = ecore_con_url_new(argv[1]);
74 printf("error when creating ecore con url object.\n");
78 ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, _url_data_cb, NULL);
79 ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _url_complete_cb, NULL);
81 ecore_con_url_additional_header_add(ec_url, "User-Agent", "Ecore_Con client");
83 ecore_con_url_cookies_init(ec_url);
84 if (cmd != 'c' && cmd != 's')
85 ecore_con_url_cookies_file_add(ec_url, COOKIEJAR);
86 ecore_con_url_cookies_jar_file_set(ec_url, COOKIEJAR);
91 printf("Cleaning previously set cookies.\n");
92 ecore_con_url_cookies_clear(ec_url);
95 case 's': // clear session
96 printf("Cleaning previously set session cookies.\n");
97 ecore_con_url_cookies_session_clear(ec_url);
100 case 'i': // ignore session
101 printf("Ignoring old session cookies.\n");
102 ecore_con_url_cookies_ignore_old_session_set(ec_url, EINA_TRUE);
105 r = ecore_con_url_get(ec_url);
108 printf("could not realize request.\n");
112 ecore_main_loop_begin();
115 ecore_con_url_free(ec_url);
117 ecore_con_url_shutdown();
118 ecore_con_shutdown();