Reimplemented http_client using the ocurl library#127
Conversation
This commit reimplements the http_client module by using the ocurl library. This should add support for the https protocol.
2455e3f to
91ee6c6
Compare
ygrek
left a comment
There was a problem hiding this comment.
yes, getting there
didn't review http_client.ml completely yet
xOneca
left a comment
There was a problem hiding this comment.
I was going to test this PR, but found some issues with the configure script.
Also made a suggestion to use the app name instead of the library name as User-Agent.
Now that compiles for me, I'll be testing it some time...
There was a problem hiding this comment.
The changes in this file do not match configure.in and will be overwritten by running autoconf. Specially important with the two new exit 1 that only exist here.
There was a problem hiding this comment.
Not sure why there are both. Maybe I'm supposed to generate the configure script and version it.
|
|
||
| ICONS_CMXA=icons.cmxa | ||
|
|
||
| LIBS_opt += $(OCAMLLIB)/threads/threads.cmxa |
There was a problem hiding this comment.
Shouldn't be searched using ocamlfind, as is done with Curl?
There was a problem hiding this comment.
Don't know if there is a way to do it with ocamlfind alone:
# ocamlfind query threads
/usr/lib/ocaml
| let def_user_agent = | ||
| let ua = Curl.version_info () in | ||
| let v = ua.Curl.version in | ||
| Printf.sprintf "curl/%s" v |
There was a problem hiding this comment.
Why not identify the real application making the request? I would use MLDonkey/x.y.z or, if you prefer, MLDonkey/x.y.z curl/a.b.c. (See example in RFC 9110 § User-Agent)
There was a problem hiding this comment.
TcpBufferedSocket.connect is using the first form for the proxy mode:
mldonkey/src/utils/net/tcpBufferedSocket.ml
Line 1355 in 0d44635
There was a problem hiding this comment.
Also, there is a global option, used in many places:
mldonkey/src/daemon/common/commonOptions.ml
Lines 1017 to 1019 in 0d44635
The value default uses MLDonkey/x.y.z format.
There was a problem hiding this comment.
My patch should only switch the default from wget to curl. Callers already pass in the proper user agent.
|
Also, I suppose GitHub workflow now needs |
xOneca
left a comment
There was a problem hiding this comment.
Hi @carlonluca,
Thanks for your updates!
I think I didn't explain the changes correctly, so here is a second review round for the Autoconf files.. 😄
|
So, here I was thinking this was the only HTTP client implementation in MLDonkey, and in fact there are two! 😕 As I can see, the HTTP client in this PR is used only for:
And It seems to download the torrent file, but then fails to detect that it is, in fact, a torrent file and the torrent is not enqueued for download. Tried both HTTP and HTTPS. 😞 Seems to be parsing headers as the name of the file? Maybe searching the name in the headers? 🤔 |
|
Hello, Much time has passed since I sent this PR, but I think torrent files are downloaded with the new implementation. In fact, I tested your link and also this one https://releases.ubuntu.com/25.04/ubuntu-25.04-desktop-amd64.iso.torrent. Both started immediately. I remember I had to fix multiple bugs related to this problem. Can you confirm you are not able to download that torrent you provided? |
|
Ok, I suspect I missed some commits in this PR. I probably restricted this PR to the HTTPS client itself. This may fix the issue you are seeing: carlonluca/mldonkey@d4592d7. My fork includes this, but I can't find it in this PR. Unfortunately my fork has diverged quite a bit. I'll have to go through everything again and see if something else is missing. In the meantime, thanks for your review. I'll work on what is missing. |
|
Ok, sorry, it seems you may need more than this PR to get proper HTTPS for bittorrent support. This is what I have in my fork: https://github.com/carlonluca/mldonkey/commits/dev/. You probably want to use that if you want bittorrent to work properly. This PR is strictly for the client. |
Co-authored-by: xOneca <xoneca@gmail.com>
Co-authored-by: xOneca <xoneca@gmail.com>
Co-authored-by: xOneca <xoneca@gmail.com>
Co-authored-by: xOneca <xoneca@gmail.com>
Co-authored-by: xOneca <xoneca@gmail.com>
Co-authored-by: xOneca <xoneca@gmail.com>
|
I moved my fork to dune and ocaml5, making this PR pretty outdated (more info here: https://bugfreeblog.duckdns.org/2025/08/mldonkey-ocaml5.html). I will not update this further so I close it. |
This commit reimplements the http_client module by using the ocurl library. This should add support for the https protocol.