static Eina_Bool __upload_completed_cb(void *data, int type, Ecore_Con_Event_Url_Complete *ev) { char buf[BUFFER_SIZE_MAX]; const Eina_List *headers = NULL, *it; const char *header = NULL; Share_Data *sd = NULL; json_object_put(jarray); jarray = NULL; json_object_put(jparent); jparent = NULL; if (ev->status != 200) { LOG("E_SHARE/" DROPNAME ": This is not supposed to happen. The server returned status code: %d\n", ev->status); return ECORE_CALLBACK_RENEW; } headers = ecore_con_url_response_headers_get(ev->url_con); EINA_LIST_FOREACH(headers, it, header) { if (strncmp(header, RECOGNITION_STRING, (sizeof(RECOGNITION_STRING) - 1)) == 0) { sd = ecore_con_url_data_get(ev->url_con); strlcpy(buf, (char*)(header + sizeof(RECOGNITION_STRING) - 1), sizeof(buf)); asprintf(&sd->url, "%s", buf); e_share_upload_completed(sd); ecore_con_url_free(ev->url_con); break; } } return ECORE_CALLBACK_CANCEL; }
Eina_Bool _url_data_cb(void *data, int type, void *event_info) { Ecore_Con_Event_Url_Data *url_data = reinterpret_cast<Ecore_Con_Event_Url_Data *>(event_info); CalaosCameraView *view = reinterpret_cast<CalaosCameraView *>(data); if (view != ecore_con_url_data_get(url_data->url_con)) return true; view->buffer.reserve(view->buffer.size() + url_data->size); std::copy(url_data->data, url_data->data + url_data->size, std::back_inserter(view->buffer)); if (view->headers.size() <= 0) { const Eina_List *headers, *l; void *str; headers = ecore_con_url_response_headers_get(url_data->url_con); EINA_LIST_FOREACH(headers, l, str) { if (!str) continue; string s((char *)str); vector<string> tokens; Utils::replace_str(s, "\n", ""); Utils::replace_str(s, "\r", ""); Utils::split(s, tokens, ":", 2); string key = tokens[0]; Utils::trim_left(key, " "); Utils::trim_right(key, " "); string val = tokens[1]; Utils::trim_left(val, " "); Utils::trim_right(val, " "); cDebugDom("camera") << "add key: \"" << key << "\" with value: \"" << val << "\""; view->headers.Add(key, val); } } view->processData(); return true; }
ret = ecore_con_url_init(); fail_if(ret != 1); ret = ecore_con_url_shutdown(); fail_if(ret != 0); } END_TEST static Eina_Bool _url_cookies_compl_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event_info) { Ecore_Con_Event_Url_Complete *url_complete = event_info; const Eina_List *headers, *l; char *str; headers = ecore_con_url_response_headers_get(url_complete->url_con); fail_if(!headers); printf("response headers:\n"); EINA_LIST_FOREACH(headers, l, str) printf("header: %s", str); ecore_con_url_cookies_jar_write(url_complete->url_con); ecore_main_loop_quit(); return EINA_TRUE; } static Ecore_Con_Url *