Merge: Work on the Curl module
authorJean Privat <jean@pryen.org>
Wed, 10 Jun 2015 01:47:05 +0000 (21:47 -0400)
committerJean Privat <jean@pryen.org>
Wed, 10 Jun 2015 01:47:05 +0000 (21:47 -0400)
Changes:
* Simplify callbacks so they do not break light FFI only engines.
* Remove about 8 classes and 3 C structures.
* Remove the custom implementation of NativeFile.
* Update style to the latest best practices. Note that it was one of the first large module based on the FFI, a lot has changed since then.
* Revamp and rename CurlMail, its API is now nicer to use:
~~~
import curl

var mail = new CurlMail("sender@example.org", ["to@example.org"], cc=["bob@example.org"])

mail.subject = "Hello From My Nit Program"
mail.body = "<h1>Here you can write HTML stuff.</h1>"

mail.headers_body["Content-Type:"] = """text/html; charset="UTF-8""""
mail.headers_body["Content-Transfer-Encoding:"] = "quoted-printable"

# Set mail server
var error = mail.set_outgoing_server("smtps://smtp.example.org:465", "user@example.org", "mypassword")
assert error == null

# Send
error = mail.execute
assert error == null
~~~

Thoughts on what's to do next:

* Extract the request API so Curl is only an implementation. The abstract API could also be implemented on Android where we can use Java services instead.
* Clean up `CurlHTTPRequest`.
* Use `Error` and differentiate between internal Curl errors and normal transfert failures.
* Replace the C structure linked to reading data and add tests for its usage.
* Add dead simple services: `Text::download: nullable String`, `Text::download_to_file(filepath: Text)`, `Text::download_to_stream(stream: Writer)` or something like that.
* Make more classes of native_curl private as we cannot make the module private because it defines the user-customizable callbacks. Some modules (neo4j) use what would be private, so it requires updating them also.

---

Should fix #936 and other problems when importing but not using Curl.
Also helps #1443 correctly report unsupported programs.

Pull-Request: #1445
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>


Trivial merge