Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Delphi: Сети > Использование ICS


Автор: Akella 8.8.2010, 12:22
Если у кого есть примеры использования, информация на русском, скидывайте в эту тему. К сожалению справка по этом компонентам на английском, но хуже, что она ещё и очень скудная.
http://www.webdelphi.ru/tag/ics/
http://www.webdelphi.ru/2010/05/ics-v-delphi-2010-sobytiya-komponenta-httpcli/
http://www.webdelphi.ru/2010/05/ics-internet-components-suite-v-delphi-2010-obshhij-obzor-komponentov/

Автор: Proxin 8.8.2010, 12:41
Поделюсь своим.
Пост/гет запрос в удобной форме.
Код

type
OwnHttpReceiveRec=record
receivedstring:string;
errorcode:word;
end;
var http:thttpcli;
function PostData(url,data:string):ownhttpreceiverec;
var datar:tstringstream;e:exception;
begin
datar:=tstringstream.create('');
try
http.sendstream:=tmemorystream.create;
except begin result.errorcode:=1;exit; end;end;
http.sendstream.write(data[1],length(data));
http.sendstream.seek(0,0);
http.rcvdstream:=datar;
http.url:=url;
try
http.post;
except on e:ehttpexception do begin result.errorcode:=e.errorcode; exit; end; end;
result.receivedstring:=datar.datastring;
result.errorcode:=0;
http.sendstream:=nil;
http.rcvdstream:=nil;
freeandnil(datar);
end;
function GetPage(url:string):ownhttpreceiverec;
var datar:tstringstream;e:exception;
begin
datar:=tstringstream.create('');
//if  then begin result.errorcode:=1; exit; end;
try
http.rcvdstream:=datar;
except begin result.errorcode:=1;exit; end;end;
http.url:=url;
try
http.get;
except on e:ehttpexception do begin result.errorcode:=e.errorcode; exit; end; end;
result.receivedstring:=datar.datastring;
result.errorcode:=0;
http.sendstream:=nil;
http.rcvdstream:=nil;
freeandnil(datar);
end;

Автор: Akella 8.8.2010, 16:24
Proxin, отформатировал бы код, а

Автор: Proxin 8.8.2010, 17:42
всмысле?

Автор: Akella 10.8.2010, 15:53
Код

type
  OwnHttpReceiveRec=record
  receivedstring:string;
  errorcode:word;
end;

var
  http:thttpcli;

function PostData(url,data:string):ownhttpreceiverec; var datar:tstringstream;e:exception;
begin
  datar:=tstringstream.create('');
  try
    http.sendstream:=tmemorystream.create;
    except
      begin
        result.errorcode:=1;
        exit;
      end;
    end;

и т.д.

Автор: Akella 13.9.2010, 09:51
http://forum.vingrad.ru/index.php?showtopic=309644&view=findpost&p=2211599

Автор: halfhope 10.3.2011, 07:54
Смотрите ниже

Автор: halfhope 2.5.2011, 22:01
Добавлю ещё оболочку, поновее.... только постом файлы не отправляются, с этим как нибудь сами.
Код


    function  Get           (const URL: string): string;
    function  Post          (const URL: string; Data:TStrings): string;
    function  GetTostream   (const URL: string):TStream;
    function  PostToStream  (const URL: string;Data:TStrings):TStream;
    function  GetAsync      (const URL: string):string;
    function  PostAsync     (const URL: string; Data: TStrings):string;

и аналогично у sslHttpCli

Если вы используете ssl, не забудьте указать в conditional defines - "USE_SSL"

Автор: Akella 30.12.2011, 14:49
http://darklibr.narod.ru/texts/socket.html http://forum.vingrad.ru/act-Print/client/printer/f-86/t-93663.html

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)