mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-16 00:05:55 +01:00
Added more comments to ResponseFilterBrowser and fixed a couple of bugs
- Move unit in the "uses" section. - Return RESPONSE_FILTER_DONE when all data has been written.
This commit is contained in:
parent
9d1c1ac052
commit
a6d948a5c4
@ -50,7 +50,7 @@ object ResponseFilterBrowserFrm: TResponseFilterBrowserFrm
|
|||||||
Margins.Right = 5
|
Margins.Right = 5
|
||||||
Align = alClient
|
Align = alClient
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
Text = 'https://www.wikipedia.org/'
|
Text = 'https://www.briskbard.com'
|
||||||
ExplicitHeight = 21
|
ExplicitHeight = 21
|
||||||
end
|
end
|
||||||
object Panel1: TPanel
|
object Panel1: TPanel
|
||||||
@ -88,7 +88,7 @@ object ResponseFilterBrowserFrm: TResponseFilterBrowserFrm
|
|||||||
Height = 20
|
Height = 20
|
||||||
Align = alRight
|
Align = alRight
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
Text = 'index-475f3bca23.js'
|
Text = 'script.js'
|
||||||
ExplicitHeight = 21
|
ExplicitHeight = 21
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -44,13 +44,12 @@ interface
|
|||||||
uses
|
uses
|
||||||
{$IFDEF DELPHI16_UP}
|
{$IFDEF DELPHI16_UP}
|
||||||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
||||||
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, System.SyncObjs,
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, System.SyncObjs, Vcl.ComCtrls,
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Windows, Messages, SysUtils, Variants, Classes, Graphics,
|
Windows, Messages, SysUtils, Variants, Classes, Graphics,
|
||||||
Controls, Forms, Dialogs, StdCtrls, ExtCtrls, SyncObjs,
|
Controls, Forms, Dialogs, StdCtrls, ExtCtrls, SyncObjs, ComCtrls,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFConstants, uCEFTypes, uCEFResponseFilter,
|
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFConstants, uCEFTypes, uCEFResponseFilter;
|
||||||
Vcl.ComCtrls;
|
|
||||||
|
|
||||||
const
|
const
|
||||||
STREAM_COPY_COMPLETE = WM_APP + $B00;
|
STREAM_COPY_COMPLETE = WM_APP + $B00;
|
||||||
@ -147,6 +146,19 @@ uses
|
|||||||
// 2. TChromium.OnClose sends a CEFBROWSER_DESTROY message to destroy CEFWindowParent1 in the main thread, which triggers the TChromium.OnBeforeClose event.
|
// 2. TChromium.OnClose sends a CEFBROWSER_DESTROY message to destroy CEFWindowParent1 in the main thread, which triggers the TChromium.OnBeforeClose event.
|
||||||
// 3. TChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
|
// 3. TChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
|
||||||
|
|
||||||
|
// TCustomResponseFilter.OnFilter event might be called multiple times when the resource is too big. In that case the resource will be split into
|
||||||
|
// "chunks of data" and each chunk will be passed in the "data_in" parameter.
|
||||||
|
|
||||||
|
// For example, if the original resource is 95 Kb long you could see that the TCustomResponseFilter.OnFilter event is triggered 10 times with
|
||||||
|
// different "data_in_size" values.
|
||||||
|
|
||||||
|
// If you replace the original resource with a shorter resource then you might need less chucks to send the data. In that case you would just set
|
||||||
|
// "aResult" to RESPONSE_FILTER_DONE when you write the last chunk of the new resource.
|
||||||
|
|
||||||
|
// If you replace the original resource with a larger resource then you might need more chunks to send all the data. In that case you would set
|
||||||
|
// "aResult" to RESPONSE_FILTER_NEED_MORE_DATA in the last chunk of the original resource. This will trigger the TCustomResponseFilter.OnFilter event
|
||||||
|
// again and you will be able to send another chunk.
|
||||||
|
|
||||||
procedure TResponseFilterBrowserFrm.Filter_OnFilter(Sender: TObject;
|
procedure TResponseFilterBrowserFrm.Filter_OnFilter(Sender: TObject;
|
||||||
data_in : Pointer;
|
data_in : Pointer;
|
||||||
data_in_size : NativeUInt;
|
data_in_size : NativeUInt;
|
||||||
@ -193,9 +205,12 @@ begin
|
|||||||
// Send the STREAM_COPY_COMPLETE message only if the server sent the data size in
|
// Send the STREAM_COPY_COMPLETE message only if the server sent the data size in
|
||||||
// a Content-Length header and we can compare it with the stream size
|
// a Content-Length header and we can compare it with the stream size
|
||||||
if not(FRscCompleted) and (FRscSize <> -1) and (FRscSize = FStream.Size) then
|
if not(FRscCompleted) and (FRscSize <> -1) and (FRscSize = FStream.Size) then
|
||||||
FRscCompleted := PostMessage(Handle, STREAM_COPY_COMPLETE, 0, 0);
|
begin
|
||||||
|
FRscCompleted := PostMessage(Handle, STREAM_COPY_COMPLETE, 0, 0);
|
||||||
aResult := RESPONSE_FILTER_NEED_MORE_DATA;
|
aResult := RESPONSE_FILTER_DONE;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
aResult := RESPONSE_FILTER_NEED_MORE_DATA;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
except
|
except
|
||||||
|
Loading…
Reference in New Issue
Block a user