Einzelnen Beitrag anzeigen

hinnack

Registriert seit: 18. Nov 2004
22 Beiträge
 
#5

Re: Webbrowser Daten per Post werden nicht komplett übertrag

  Alt 6. Nov 2007, 20:36
also:
TEmbeddedWb hat eine Download Komponente (IEDownloadPtr in meinem Beispiel unten). Diese verwende ich wie folgt, um Daten zu posten:

Delphi-Quellcode:
   IEDownloadPtr.DownloadMethod := dlFile;
   IEDownloadPtr.DownloadDir := '';
   IEDownloadPtr.Options := IEDownloadPtr.Options - [Asynchronous];
   IEDownloadPtr.Method := Custom;
   IEDownloadPtr.CustomVerb := 'POST';
   IEDownloadPtr.UserName := 'meinlogon';
   IEDownloadPtr.Password := 'sehr sicher';
   IEDownloadPtr.PostData := PostParams;
   IEDownloadPtr.AdditionalHeader.Clear;
   If AdditionalHeader <> 'then
      IEDownloadPtr.AdditionalHeader.Add(AdditionalHeader);
   BS := IEDownloadPtr.Go(URL, DestinationFile);
   try
      try
         while not (BS.State in [Canceled, Finished, IEDownload.Error]) do
            Sleep(100);
         Result := BS.ResponseHeader;
         if (BS.ResponseCode <> 200) and (BS.ResponseCode <> 206) and (BS.ResponseCode <> 304) then
            raise Exception.Create('HTTP error ' + IntToStr(BS.ResponseCode));
      finally
         FreeAndNil(BS);
      end;
   except
      on e: Exception do
         raise Exception.Create(e.Message + ' on ' + URL);
   end;
wobei Postparams die URL-encodedten Post-Daten enthalten sollte (var1=xxx&var2=yyy)
AdditionalHeader den Content-Type (Content-Type: multipart/form-data)

man kann die Antwort des Webservers natürlich auch in einen Stream laden, statt in ein File (DestinationFile)

Gruss

Hinnack
  Mit Zitat antworten Zitat