OndataSent???? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- lazzaro2023 · 2024-11-20 18:33 Hi everyone, I have the following code: Quoteprogram OndataSent; uses   SysUtils, fphttpclient; procedure OnDataSent(Sender: TObject; AContentLength, ACurrentPos: Int64); begin   WriteLn('Data sent: ', ACurrentPos, ' of ', AContentLength); end; var   Client: TFPHTTPClient; begin   Client := TFPHTTPClient.Create(nil);   try     Client.OnDataSent := @OnDataSent;     Client.Get('http://mysite.com');   finally     Client.Free;   end; end. When I compile it, I get the following error: Quoteondatasent.lpr(16,12) Error: identifier idents no member "OnDataSent" Where did I go wrong? ---------------------------------------------------------------------- TRon · 2024-11-20 19:06 Quote from: lazzaro2023 on November 20, 2024, 07:33:13 pmWhere did I go wrong? Besides the obvious program name clashing with your procedure and assigning a normal procedure to a method you are probably using FPC 3.2.2. afaik ondatasent is only available since trunk. ---------------------------------------------------------------------- lazzaro2023 · 2024-11-20 20:28 I'm using FPC 3.2.2 and I don't have any news about updates. If you have this information, can you share the link where I can download the update?" But I did a quick search online and came across this link: https://www.freepascal.org/daily/packages/fcl- web/fphttpclient/tfphttpclient.ondatasent.html ---------------------------------------------------------------------- Warfley · 2024-11-20 20:39 FPC 3.2.2 is the most current stable version. It came out in August of 2021. There is still development on the Development branch, but it's not stable enough to make a new release. The documentation link you've sent is from the Daily documentation build, which is based on the development branch. Looking at the documentation page you can see: QuoteDocumentation generated on: 2023-03-18Which is 2.5 years after the release of 3.2.2 ---------------------------------------------------------------------- TRon · 2024-11-20 21:18 Could not have explained it better than warfley did. Quote from: lazzaro2023 on November 20, 2024, 09:28:00 pmI'm using FPC 3.2.2 and I don't have any news about updates. If you have this information, can you share the link where I can download the update?" There is no download other than the sources from the development tree (aka main aka trunk) of the compiler. That means that if you really need this functionality you would have to build, install and configure the (trunk) compiler manually yourself. ---------------------------------------------------------------------- dsiders · 2024-11-20 21:26 Quote from: TRon on November 20, 2024, 10:18:49 pmThat means that if you really need this functionality you would have to build, install and configure the (trunk) compiler manually yourself. Getting an FPC trunk compiler is the one (and only) reason that I use fpcupdeluxe. ---------------------------------------------------------------------- TRon · 2024-11-20 21:29 Quote from: dsiders on November 20, 2024, 10:26:29 pmGetting an FPC trunk compiler is the one (and only) reason that I use fpcupdeluxe. You are absolutely right. I forgot to mention that. ---------------------------------------------------------------------- Warfley · 2024-11-20 21:48 Theoretically there are also daily builds you can just download, and at least for linux theres also an install script, but with the main branch changing so rapidly it's better to build it from source and update via git. But I would generally not recommend if you are inexperienced with lazarus and fpc to use the development branch, as it is quite unstable, sometimes stops building on certain systems, requiring rollbacks etc. If you don't know what you are doing it can be quite painful ---------------------------------------------------------------------- TRon · 2024-11-20 21:58 I second that recommendation. If you don't really need the functionality or can work around it then stay away from trunk. Practice has shown that it is able to cause more headaches than it is able to solve (I for instance only update my installed trunk version once in a while but only after separate testing to make sure it is stable enough to be able to actually work with). The people that benefits most (or have a need) are those that either experience issues with the normal releases or those that are on an architecture that is only (fairly) recently supported by FPC. Unfortunately things seem to move at such a pace that almost everyone requires trunk/main these days ---------------------------------------------------------------------- MarkMLl · 2024-11-20 22:10 Quote from: TRon on November 20, 2024, 10:58:17 pmUnfortunately things seem to move at such a pace that almost everyone requires trunk/main these days  On more than one occasion I've taken stick because I've built FPC from the published fpcbuild archive that's supposed to represent a specific version. Based on my experience with other projects I try to avoid relying in Git because (a) a Git archive consumes a substantial amount of space for no advantage and (b) if relying on Git it's difficult to specify that I'm at a particular checkpoint, from which I can move backwards (or forwards) incrementally. MarkMLl ---------------------------------------------------------------------- Warfley · 2024-11-21 04:51 Quote from: TRon on November 20, 2024, 10:58:17 pmUnfortunately things seem to move at such a pace that almost everyone requires trunk/main these days  The question would be if it would be possible to make a release of the newest RTL and FCL packages without a new release of the Compiler. The Compiler featuresay not be stable yet, but the updates to FCL and RTL probably are on a much better track ---------------------------------------------------------------------- rvk · 2024-11-21 09:17 Quote from: lazzaro2023 on November 20, 2024, 09:28:00 pmI'm using FPC 3.2.2 and I don't have any news about updates. If you have this information, can you share the link where I can download the update?" But I did a quick search online and came across this link: https://www.freepascal.org/daily/packages/fcl- web/fphttpclient/tfphttpclient.ondatasent.html @lazzaro2023 if you can't find or can't compile the latest version with this addition... you can also look at a TFPHTTPClient helper I once posted. https://forum.lazarus.freepascal.org/index.php/topic,34297.msg224577.h tml#msg224577 It implements OnDataSent event for TFPHTTPClient by overriding the standard TFPHTTClient. Just set ufphttphelper as last unit in your uses of the interface (after fphttpclient). I haven't tested this for years though ---------------------------------------------------------------------- lazzaro2023 · 2024-11-21 21:01 Thanks for the tip, but when I use this unit, I get the following error: Quote ufphttphelper.pas(104,3) Error: Identifier not found "Socket" ufphttphelper.pas(106,41) Error: Identifier not found "Socket" Where did I go wrong?" ---------------------------------------------------------------------- TRon · 2024-11-21 21:10 Quote from: MarkMLl on November 20, 2024, 11:10:39 pmOn more than one occasion I've taken stick because I've built FPC from the published fpcbuild archive that's supposed to represent a specific version. I use my own script that allows for me to set either the commit hash or branch/tag name. That provides me enough wiggle-room to play with  But indeed there are times when it can be difficult to find a hash that is able to build. I've tried that with a script solution as well (it cycles through tags and reports back on success/failure) but I'm not satisfied with that solution (yet). QuoteBased on my experience with other projects I try to avoid relying in Git because (a) a Git archive consumes a substantial amount of space for no advantage and (b) if relying on Git it's difficult to specify that I'm at a particular checkpoint, from which I can move backwards (or forwards) incrementally. It might be we have a different use case for trunk. I use 2 myself. One that I carefully inspect and use for development in order to either fix (existing) bugs and let my code-base slightly move towards new features (or test if that can be done) and the second for testing purpose, fixing bugs, craft patches etc. The former is less updated and only when there is need for me while the second is usually never a 'real' install. In the former was, I install the compiler itself with make and don't rely on the git sources because indeed it carries around a lot of (in my case unneeded) baggage. in the second form I more or less have to use git in order to be able to craft patches (well could be done alternatively but such patches will usually not be accepted  ). ---------------------------------------------------------------------- rvk · 2024-11-21 21:18 Quote from: lazzaro2023 on November 21, 2024, 10:01:43 pmThanks for the tip, but when I use this unit, I get the following error: Quote ufphttphelper.pas(104,3) Error: Identifier not found "Socket" ufphttphelper.pas(106,41) Error: Identifier not found "Socket" Where did I go wrong?" O, sorry, it seems I needed to change the fphttpclient.pp for that because socket variable wasn't exposed. And because that's FPC, the change won't compule when recompiling Lazarus  Quote from: rvk on October 07, 2016, 11:30:34 amThe only problem I had was that "socket" wasn't exposed in TFPHTTPClient. And that's a serious problem. So I had to change the original fphttpclient.pp. I just added the following line to my copied fphttpclient.pp and I could use socket in my helper and stream. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     Property Socket: TInetSocket read FSocket; But I do agree with JuhaManninen. An upload-callback as well as Abort- option should be added to TFPHTTPClient. It would even be a very small patch. The Download-progress is already there in the DoDataRead (which calls OnDataReceived). So the FOnDataSent would simple to implement. Only 3 lines in TFPHTTPClient but with a complete CopyFromStreamToStream() because TStream.CopyFrom() doesn't have a progress-option. Or should that one be added too I was also very surprised to see the download-progress option in TFPHTTPClient was added but upload-progress option was left out. ---------------------------------------------------------------------- MarkMLl · 2024-11-22 07:35 Quote from: TRon on November 21, 2024, 10:10:25 pmIn the former was, I install the compiler itself with make and don't rely on the git sources because indeed it carries around a lot of (in my case unneeded) baggage. in the second form I more or less have to use git in order to be able to craft patches (well could be done alternatively but such patches will usually not be accepted  ). My usual MO for a new development system is to install the earliest- viable FPC binaries from the published tarball, then work forwards with published fpcbuild sources. That is obviously sensitive to disruption such as when Debian moved from 11 to 12, as well as flailing around regarding which version of FPC was required to build the current release. MarkMLl ---------------------------------------------------------------------- PascalDragon · 2024-11-24 15:32 Quote from: Warfley on November 21, 2024, 05:51:52 amQuote from: TRon on November 20, 2024, 10:58:17 pmUnfortunately things seem to move at such a pace that almost everyone requires trunk/main these days  The question would be if it would be possible to make a release of the newest RTL and FCL packages without a new release of the Compiler. The Compiler featuresay not be stable yet, but the updates to FCL and RTL probably are on a much better track This is essentially the case for 3.2.4. Many/most of the additions/changes for RTL and packages were merged there except those that rely on new compiler features or were too much manual merging would have been necessary. Any other approach will not work as it would be too much maintenance effort on our end.