forked from enlightenment/efl
fixup: http
This commit is contained in:
parent
535f111bfa
commit
5c778e2b15
|
@ -183,7 +183,7 @@ static const Ecore_Getopt options = {
|
|||
ECORE_GETOPT_STORE_BOOL('r', "allow-redirects", "allow redirections by following 'Location:' headers"),
|
||||
ECORE_GETOPT_STORE_DOUBLE('t', "connect-timeout", "timeout in seconds for the connection phase"),
|
||||
ECORE_GETOPT_APPEND('H', "header", "Add custom headers. Format must be 'Key: Value'", ECORE_GETOPT_TYPE_STR),
|
||||
ECORE_GETOPT_APPEND('F', "form", "Add form field. Format must be 'key=value'", ECORE_GETOPT_TYPE_STR),
|
||||
ECORE_GETOPT_STORE_STR('X', "proxy", "Set a specific proxy for the connection"),
|
||||
ECORE_GETOPT_STORE_STR('i', "input-file", "Input file to use when uploading"),
|
||||
ECORE_GETOPT_VERSION('V', "version"),
|
||||
ECORE_GETOPT_COPYRIGHT('C', "copyright"),
|
||||
|
@ -210,12 +210,12 @@ main(int argc, char **argv)
|
|||
char *address = NULL;
|
||||
char *output_fname = NULL;
|
||||
char *input_fname = NULL;
|
||||
char *proxy = NULL;
|
||||
Eina_Bool quit_option = EINA_FALSE;
|
||||
Eina_Bool authentication_restricted = EINA_FALSE;
|
||||
Eina_Bool allow_redirects = EINA_TRUE;
|
||||
double timeout_dial = 30.0;
|
||||
Eina_List *headers = NULL;
|
||||
Eina_List *form_fields = NULL;
|
||||
Ecore_Getopt_Value values[] = {
|
||||
ECORE_GETOPT_VALUE_STR(method),
|
||||
ECORE_GETOPT_VALUE_STR(primary_mode_str),
|
||||
|
@ -227,7 +227,7 @@ main(int argc, char **argv)
|
|||
ECORE_GETOPT_VALUE_BOOL(allow_redirects),
|
||||
ECORE_GETOPT_VALUE_DOUBLE(timeout_dial),
|
||||
ECORE_GETOPT_VALUE_LIST(headers),
|
||||
ECORE_GETOPT_VALUE_LIST(form_fields),
|
||||
ECORE_GETOPT_VALUE_STR(proxy),
|
||||
ECORE_GETOPT_VALUE_STR(input_fname),
|
||||
|
||||
/* standard block to provide version, copyright, license and help */
|
||||
|
@ -316,6 +316,7 @@ main(int argc, char **argv)
|
|||
efl_net_dialer_http_version_set(efl_self, http_version),
|
||||
efl_net_dialer_http_authentication_set(efl_self, username, password, authentication_method, authentication_restricted),
|
||||
efl_net_dialer_http_allow_redirects_set(efl_self, allow_redirects),
|
||||
efl_net_dialer_proxy_set(efl_self, proxy),
|
||||
efl_net_dialer_timeout_dial_set(efl_self, timeout_dial),
|
||||
efl_event_callback_array_add(efl_self, dialer_cbs(), NULL));
|
||||
|
||||
|
@ -333,12 +334,6 @@ main(int argc, char **argv)
|
|||
free(str);
|
||||
}
|
||||
|
||||
EINA_LIST_FREE(form_fields, str)
|
||||
{
|
||||
fprintf(stderr, "TODO: form_field %s", str);
|
||||
free(str);
|
||||
}
|
||||
|
||||
waiting = 1;
|
||||
if (efl_net_dialer_http_primary_mode_get(dialer) == EFL_NET_DIALER_HTTP_PRIMARY_MODE_UPLOAD)
|
||||
waiting++;
|
||||
|
@ -377,13 +372,15 @@ main(int argc, char **argv)
|
|||
"INFO: - version=%d\n"
|
||||
"INFO: - allow_redirects=%d\n"
|
||||
"INFO: - timeout_dial=%fs\n"
|
||||
"INFO: - proxy=%s\n"
|
||||
"INFO: - request headers:\n",
|
||||
efl_net_dialer_address_dial_get(dialer),
|
||||
efl_net_dialer_http_method_get(dialer),
|
||||
efl_net_dialer_http_primary_mode_get(dialer),
|
||||
efl_net_dialer_http_version_get(dialer),
|
||||
efl_net_dialer_http_allow_redirects_get(dialer),
|
||||
efl_net_dialer_timeout_dial_get(dialer));
|
||||
efl_net_dialer_timeout_dial_get(dialer),
|
||||
efl_net_dialer_proxy_get(dialer));
|
||||
|
||||
itr = efl_net_dialer_http_request_headers_get(dialer);
|
||||
EINA_ITERATOR_FOREACH(itr, header)
|
||||
|
|
|
@ -174,6 +174,7 @@ typedef struct
|
|||
Efl_Net_Dialer_Http_Curlm *cm;
|
||||
Ecore_Fd_Handler *fdhandler;
|
||||
Eina_Stringshare *address_dial;
|
||||
Eina_Stringshare *proxy;
|
||||
Eina_Stringshare *address_local;
|
||||
Eina_Stringshare *address_remote;
|
||||
Eina_Stringshare *method;
|
||||
|
@ -777,8 +778,6 @@ _efl_net_dialer_http_send_data(char *buffer, size_t count, size_t nitems, void *
|
|||
pd->send.slice.len -= rw_slice.len;
|
||||
pd->send.slice.bytes += rw_slice.len;
|
||||
|
||||
static int i = 0; i++; if (i % 5 == 0) return 0x10000000;
|
||||
|
||||
if (rw_slice.len == 0)
|
||||
{
|
||||
pd->pause |= CURLPAUSE_SEND;
|
||||
|
@ -992,6 +991,7 @@ _efl_net_dialer_http_efl_object_destructor(Eo *o, Efl_Net_Dialer_Http_Data *pd)
|
|||
}
|
||||
|
||||
eina_stringshare_replace(&pd->address_dial, NULL);
|
||||
eina_stringshare_replace(&pd->proxy, NULL);
|
||||
eina_stringshare_replace(&pd->address_local, NULL);
|
||||
eina_stringshare_replace(&pd->address_remote, NULL);
|
||||
eina_stringshare_replace(&pd->method, NULL);
|
||||
|
@ -1017,8 +1017,6 @@ _efl_net_dialer_http_efl_net_dialer_dial(Eo *o, Efl_Net_Dialer_Http_Data *pd, co
|
|||
|
||||
efl_net_dialer_address_dial_set(o, address);
|
||||
|
||||
// TODO: proxy
|
||||
|
||||
r = curl_easy_setopt(pd->easy, CURLOPT_HTTPHEADER, pd->request.headers);
|
||||
if (r != CURLE_OK)
|
||||
{
|
||||
|
@ -1082,6 +1080,25 @@ _efl_net_dialer_http_efl_net_dialer_connected_get(Eo *o EINA_UNUSED, Efl_Net_Dia
|
|||
return pd->connected;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_net_dialer_http_efl_net_dialer_proxy_set(Eo *o EINA_UNUSED, Efl_Net_Dialer_Http_Data *pd, const char *proxy_url)
|
||||
{
|
||||
CURLcode r;
|
||||
|
||||
r = curl_easy_setopt(pd->easy, CURLOPT_PROXY, proxy_url);
|
||||
if (r != CURLE_OK)
|
||||
ERR("dialer=%p could not set proxy to '%s': %s",
|
||||
o, proxy_url, curl_easy_strerror(r));
|
||||
|
||||
eina_stringshare_replace(&pd->proxy, proxy_url);
|
||||
}
|
||||
|
||||
EOLIAN static const char *
|
||||
_efl_net_dialer_http_efl_net_dialer_proxy_get(Eo *o EINA_UNUSED, Efl_Net_Dialer_Http_Data *pd)
|
||||
{
|
||||
return pd->proxy;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_efl_net_dialer_http_efl_net_dialer_timeout_dial_set(Eo *o, Efl_Net_Dialer_Http_Data *pd, double seconds)
|
||||
{
|
||||
|
|
|
@ -295,6 +295,7 @@ class Efl.Net.Dialer.Http (Efl.Loop_User, Efl.Net.Dialer, Efl.Io.Reader, Efl.Io.
|
|||
Efl.Net.Dialer.dial;
|
||||
Efl.Net.Dialer.address_dial;
|
||||
Efl.Net.Dialer.connected;
|
||||
Efl.Net.Dialer.proxy;
|
||||
Efl.Net.Dialer.timeout_dial;
|
||||
Efl.Net.Socket.address_local;
|
||||
Efl.Net.Socket.address_remote;
|
||||
|
|
Loading…
Reference in New Issue