Good day! By the client I connect to the server, transfer the name of the file, the path where to download the file and transfer the server this file to the client via tsp. Now there was a question how to do the same thing only via url. Here are the projects http://rgho.st/8RRsrCYPx
Server part: (Port and ip are specified in server settings)
procedure TServerForm.BtStartClick(Sender: TObject); begin Activity:=not Activity; if Activity=true then begin BtStart.Caption:='Стоп'; MyHTTPServer.Active:=True; end else begin BtStart.Caption:='Старт'; MyHTTPServer.Active:=False; end; end; procedure TServerForm.MyHTTPServerCommandGet(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo); begin MessageDlg('1111111', mtError, [mbOK], 0); AResponseInfo.ContentStream:=TFileStream.Create('d:/work/11.txt',fmOpenRead); end; Client part:
begin MyHTTPClient.BoundIP:=EdHost.Text; MyHTTPClient.BoundPort:=strtoint(EdPort.Text); try MyHTTPClient.Connect; except MessageDlg('Не удается соединиться с сервером', mtError, [mbOK], 0); Exit; end; stream:=TFileStream.Create(EdSavepath.Text, fmCreate); ForceDirectories(ExtractFileDir(EdSavepath.Text)); try MyHTTPClient.Get(EdSend.Text,stream); finally MyHTTPClient.Free; stream.Free; end;