Recent

Author Topic: OndataSent????  (Read 3569 times)

lazzaro2023

  • New Member
  • *
  • Posts: 36
OndataSent????
« on: November 20, 2024, 07:33:13 pm »
Hi everyone, I have the following code:
Quote
program 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:
Quote
ondatasent.lpr(16,12) Error: identifier idents no member "OnDataSent"

Where did I go wrong?

TRon

  • Hero Member
  • *****
  • Posts: 3822
Re: OndataSent????
« Reply #1 on: November 20, 2024, 08:06:56 pm »
Where 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.
I do not have to remember anything anymore thanks to total-recall.

lazzaro2023

  • New Member
  • *
  • Posts: 36
Re: OndataSent????
« Reply #2 on: November 20, 2024, 09:28:00 pm »
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

  • Hero Member
  • *****
  • Posts: 1856
Re: OndataSent????
« Reply #3 on: November 20, 2024, 09:39:19 pm »
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:
Quote
Documentation generated on: 2023-03-18
Which is 2.5 years after the release of 3.2.2

TRon

  • Hero Member
  • *****
  • Posts: 3822
Re: OndataSent????
« Reply #4 on: November 20, 2024, 10:18:49 pm »
Could not have explained it better than warfley did.

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?"
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.
I do not have to remember anything anymore thanks to total-recall.

dsiders

  • Hero Member
  • *****
  • Posts: 1327
Re: OndataSent????
« Reply #5 on: November 20, 2024, 10:26:29 pm »
That 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.
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

TRon

  • Hero Member
  • *****
  • Posts: 3822
Re: OndataSent????
« Reply #6 on: November 20, 2024, 10:29:40 pm »
Getting an FPC trunk compiler is the one (and only) reason that I use fpcupdeluxe.
You are absolutely right. I forgot to mention that.
I do not have to remember anything anymore thanks to total-recall.

Warfley

  • Hero Member
  • *****
  • Posts: 1856
Re: OndataSent????
« Reply #7 on: November 20, 2024, 10:48:08 pm »
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

  • Hero Member
  • *****
  • Posts: 3822
Re: OndataSent????
« Reply #8 on: November 20, 2024, 10:58:17 pm »
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  :-\
I do not have to remember anything anymore thanks to total-recall.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8138
Re: OndataSent????
« Reply #9 on: November 20, 2024, 11:10:39 pm »
Unfortunately 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
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Warfley

  • Hero Member
  • *****
  • Posts: 1856
Re: OndataSent????
« Reply #10 on: November 21, 2024, 05:51:52 am »
Unfortunately 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

  • Hero Member
  • *****
  • Posts: 6643
Re: OndataSent????
« Reply #11 on: November 21, 2024, 10:17:38 am »
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
@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.html#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

  • New Member
  • *
  • Posts: 36
Re: OndataSent????
« Reply #12 on: November 21, 2024, 10:01:43 pm »
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

  • Hero Member
  • *****
  • Posts: 3822
Re: OndataSent????
« Reply #13 on: November 21, 2024, 10:10:25 pm »
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.
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).

Quote
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.
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  :) ).
I do not have to remember anything anymore thanks to total-recall.

rvk

  • Hero Member
  • *****
  • Posts: 6643
Re: OndataSent????
« Reply #14 on: November 21, 2024, 10:18:18 pm »
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?"
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  :-X

The 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][+][-]
  1.     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.

 

TinyPortal © 2005-2018