Forum > Networking and Web Programming

[SOLVED] TFPHTTPClient.Get(URL) / SimpleGet(URL) do not get the full HTML

(1/2) > >>

lebao3105:
I am new to fphttpclient. Here is my code:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function downloadItem(const URL: ansistring): string;var http: TFPHTTPClient;begin    // http := TFPHTTPClient.Create(nil);    //try    //     result := http.Get(URL);    //finally    //     http.Free;    result := TFPHTTPClient.SimpleGet(URL);end; 
When I try this for this site: https://cdn.nickchan.lol/palera1n/c-rewrite/releases/, all I see that is the downloaded website HTML as expected, but partial:


--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---<html><head><title>Index of /palera1n/c-rewrite/releases/</title></head><body><h1>Index of /palera1n/c-rewrite/releases/</h1><hr><pre><a href="../">../</a><a href="v2.0.0-beta.1/">v2.0.0-beta.1/</a>                                     12-Feb-2023  
The same goes for TFPHTTPClient.SimpleGet(URL). However: this works:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program dl_fphttp_b; {$mode delphi}{$ifdef windows}{$apptype console}{$endif} uses   fphttpclient,  opensslsockets; begin    writeln(TFPHttpClient.SimpleGet('https://freepascal.org')); end. 
Using TFPHTTPClient with a TStream object works.

Any ideas?

EDIT: Solved by adding {$H+} into my unit

dseligo:
It works on Windows 11, Lazarus 2.2.6, FPC 3.2.2, you didn't write what OS and version you work on.
I attached test project.
You forgot to free TFPHTTPClient.

lebao3105:

--- Quote from: dseligo on December 01, 2023, 05:03:08 am ---It works on Windows 11, Lazarus 2.2.6, FPC 3.2.2, you didn't write what OS and version you work on.
I attached test project.
You forgot to free TFPHTTPClient.

--- End quote ---

Sorry for my mistakes.

I’m using Arch Linux with Lazarus 3.0rc2 and fpc 3.2.2-9. For the missing http.Free, I forgot to add it to my post. However it still didn’t work.

TRon:

--- Quote from: lebao3105 on December 01, 2023, 05:24:55 pm ---I’m using Arch Linux with Lazarus 3.0rc2 and fpc 3.2.2-9. For the missing http.Free, I forgot to add it to my post. However it still didn’t work.

--- End quote ---
Since the resulting number of characters that you do receive seem to be around 250 ... are you perhaps using shortstring ?

Full compilable example please (including used compiler/build flags) . Anything else is just a guessing game.

dseligo:

--- Quote from: lebao3105 on December 01, 2023, 05:24:55 pm ---I’m using Arch Linux with Lazarus 3.0rc2 and fpc 3.2.2-9. For the missing http.Free, I forgot to add it to my post. However it still didn’t work.

--- End quote ---

Did you try project I attached?

Navigation

[0] Message Index

[#] Next page

Go to full version