Using HttpSend, I have struggled to understand why some pages return
no content at all when requested using THttpSend, but are perfectly
alright when requested using a browser; even after sniffing out the
headers and trying to make them as compatible as possible.

For example I have tried loading https://dspace.library.uvic.ca:8443/
using the following code:

[code]
interface

uses
 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
StdCtrls, blcksock, httpsend, ssl_openssl;

type

  Tfrm = class(TForm)
      btnSend: TButton;
      edtURL: TEdit;
      memHeader: TMemo;
      memBody: TMemo;
      procedure btnSendClick(Sender: TObject);
  end;

var
  frm: Tfrm;

implementation

{$R *.lfm}

procedure Tfrm.btnSendClick(Sender: TObject);
var ht:THttpSend;
begin
    ht := THttpSend.Create;
    ht.UserAgent := 'Mozilla/5.0 (X11; Linux i686; rv:5.0)
Gecko/20100101 Firefox/5.0';
    ht.Headers.Add('Accept: text/html');
    //ht.KeepAlive := true;
    ht.Protocol := '1.1';
    try
        if ht.HTTPMethod('GET',edtUrl.Text) then
        begin
            if(ht.Document.Size > 0) then
            begin
                ht.Document.Position := 0;
                memBody.Lines.LoadFromStream(ht.Document);
            end
            else
                memBody.Lines.Text := '(no content)';
        end;
        memHeader.Lines.Add(IntToStr(ht.ResultCode) + '  ' + ht.ResultString);
    finally
        memHeader.Lines.Text := ht.Headers.Text;
        ht.Free;
    end;
end;

[/code]

Any ideas?

I have asked the same question on the Lazarus forum but not much help
yet. So forgive me for cross-posting. Thanks.

------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to