Hi all,

Now it's time to review Ecore_Con_Url towards a better API and then
provide that as a Eo object. The current ecore_con_url will stay the
same, but the new one can have some enhancements or simplifications if
needed.

Before going into the review, the core question will be to have a
single core class with all methods even if they do not make sense (ie:
HTTP-specific) or multiple subclasses with protocol specific methods.
You can see methods split below.

A second point is whether to allow reuse of Ecore_Con_URL handle to do
other requests. Reviewing the current code and cURL documentation I
found that we may enter inconsistent behavior, for example if a POST
is done then HEAD, it will need to reset some flags and we're not
doing that. To me it looks like create for a single operation and then
destroy, creating a new one if desired is the common pattern.

Review:

 * Eo.Base change to Eo.Loop_User
 * data event: payload: conn (?), size, data. Remove conn, since the
event callback provides it.
 * complete event: payload: conn (?), code (200, 404...). Remove conn,
since the event callback provides it.
 * progress event: payload: conn (?), down/up x total/now (double?).
Remove conn, since the event callback provides it. Change from double
to off_t or uint64_t?
 * `ecore_con_url_pipeline_set(bool)/get` only usable with http, so
add that to name?

# Base

Should change:
 * `ecore_con_url_get(con)` execute a regular fetch (HTTP: GET, FTP:
download) request. GET is confusing since ressembles HTTP-only, maybe
rename to 'fetch'?
 * `ecore_con_url_head(con)` execute body-less fetch (HTTP: HEAD, FTP:
no data) request. HEAD also ressembles HTTP-only, maybe rename to
'fetch_no_body' or something like that? Suggestions?
 * `ecore_con_url_received_bytes_get(con): int` **(issue: progress is
double! change to uint64_t/off_t?)**
 * `ecore_con_url_proxy_set(con, proxy)`, take user and password to
avoid 3 functions? Maybe ask them to be url-encoded such as
http://user:pass@domain/path and then use a single string?
 * `ecore_con_url_proxy_username_set(con, username)`
 * `ecore_con_url_proxy_password_set(con, password)`
 * `ecore_con_url_url_set(con, url)` remove?

Okay:

 * `ecore_con_url_new(url): con`
 * `ecore_con_url_custom_new(url, http_method)` (works for HTTP, FTP,
IMAP, POP3, SMTP...)
 * `ecore_con_url_free(con)`
 * `ecore_con_url_fd_set(con, write_fd)` download to file (http/ftp
download, etc)
 * `ecore_con_url_verbose_set(con, bool)` set cURL verbosity
 * `ecore_con_url_data_set(con, void*)` -> `eo_key_data_set()`
 * `ecore_con_url_data_get(con)` -> `eo_key_data_get()`
 * `ecore_con_url_timeout_set(con, double)`
 * `ecore_con_url_status_code_get(con): int`
 * `ecore_con_url_response_headers_get(con): list`
 * `ecore_con_url_ssl_verify_peer_set(con, bool)`
 * `ecore_con_url_ssl_ca_set(con, file)`

To be introduced:

 * `ecore_con_url_download_bytes_get(con): uint64` to complement
`ecore_con_url_received_bytes_get()`
 * `ecore_con_url_authentication_set(con, user, pass)` general
authentication data (replaces ftp_upload() and httpauth_set()).
 * `ecore_con_url_upload_file(con, src_fname)`  works for most
protocols such http and ftp, replaces ecore_con_url_ftp_upload().
 * `ecore_con_url_upload_data(con, cb)` to upload data created by a
given function, allows streaming and pipe from other sources, not just
files.


# HTTP specific:

 * `ecore_con_url_post(con, data, len, content_type)` execute POST request
 * `ecore_con_url_http_version_set(con, ver)` set http version to use
**(issue: add http2, etc)**
 * `ecore_con_url_additional_header_add(con, key, val)` add Key: Value to header
 * `ecore_con_url_additional_headers_clear(con)` remove all headers
 * `ecore_con_url_httpauth_set(con, user, pass, safe): bool` safe
blocks plain-text authentications such as HTTP Basic. **Should be
replaced with ecore_con_url_authentication_set() +
ecore_con_url_http_authentication_method_set()**
 * `ecore_con_url_cookies_init(con)`
 * `ecore_con_url_cookies_ignore_old_session_set(con, url, bool)`
 * `ecore_con_url_cookies_clear(con)`
 * `ecore_con_url_cookies_session_clear(con)`
 * `ecore_con_url_cookies_file_add(con, file)`
 * `ecore_con_url_cookies_jar_file_set(con, file)`
 * `ecore_con_url_cookies_jar_write(con)`

To be introduced:
 * `ecore_con_url_http_authentication_method_set(con, method)` (basic,
digest, digest-ie, negotiate, ntlm, ntlm_wb, any, any safe, only)
 * `ecore_con_url_http_allow_redirects_set(con, bool)` to set
CURLOPT_FOLLOWLOCATION and allow HTTP 3xx redirects.


# FTP specific:

 * `ecore_con_url_ftp_upload(con, src_fname, user, pass, upload_dir)`
execute ftp upload. Could be removed if `ecore_con_url_upload_file()`
is added.
 * `ecore_con_url_ftp_use_epsv_set(con, epsv)`: just examples use
this, should be removed?



For further reference, you can find an analysis of users of
ecore-con-url at
https://gist.github.com/barbieri/773440bfc747d902b34b33dbbe89bd1a

-- 
Gustavo Sverzut Barbieri
--------------------------------------
Mobile: +55 (16) 99354-9890

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. http://sdm.link/zohodev2dev
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to