Slow Xojo.Net.HTTPSocket PageReceived handling of downloaded HTML file

All, when I use the Xojo.Net.HTTPSocket (of 2017R3) to download a webpage, and I try to show the downloaded file in an HTMLViewer, I observed this:

HTMLViewer1.LoadURL(Url2Download) // Fast (normal, because this is the original, online file. :wink:

HTMLViewer1.LoadURL(downloadFile.ShellPath) // OK but a bit slow (5 sec)
HTMLViewer1.LoadURL(downloadFile.NativePath) // very SLOW (30 to 60 sec)

I’m using this in the PageReceived event:

[code]Dim buffer As Text = Xojo.Core.TextEncoding.UTF8.ConvertDataToText(Content)
ResponseArea.Text = buffer

dim mbTemp as MemoryBlock = Content.Data
dim mbStr as new MemoryBlock(Content.Size)
try
mbStr.StringValue(0, mbStr.size) = mbTemp.StringValue(0, mbStr.Size)
catch OutOfBoundsException
// No value
end

dim sResponse as String
sResponse = mbStr
sResponse = trim(sResponse)
sResponse = DefineEncoding(sResponse, Encodings.UTF8)

Dim DownloadFileName As String = UrlToFilename(Url2Download) + “.htm”
Dim newFolder as FolderItem
newFolder=SpecialFolder.Documents.Child(“Downloads”)
Dim downloadFile As FolderItem = newFolder.Child(DownloadFileName)

'Dim newFile As New Xojo.IO.FolderItem(downloadFile.NativePath.ToText)

Dim t As TextOutputStream
If downloadFile <> Nil Then
t = TextOutputStream.Create(downloadFile)
t.Write(buffer)
t.Close
End If
[/code]

UrlToFilename is just an MD5 method applied to the filename.

Any idea why this code is slow or very slow?

Thanks

Why not use the FileReceived event?

I’m surprised this works at all. NativePath <> URL.