AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Delphi How to Use Indy 10 idHTTP : IOHandler value is not valid
Thema durchsuchen
Ansicht
Themen-Optionen

How to Use Indy 10 idHTTP : IOHandler value is not valid

Ein Thema von Delphi-Lover · begonnen am 15. Jun 2005 · letzter Beitrag vom 23. Okt 2008
Antwort Antwort
Seite 1 von 2  1 2      
Delphi-Lover

Registriert seit: 19. Okt 2004
Ort: Amsterdam
30 Beiträge
 
Delphi 2005 Professional
 
#1

How to Use Indy 10 idHTTP : IOHandler value is not valid

  Alt 15. Jun 2005, 12:09
Hello,

Using the idHTTP component in Indy 9 was very easy, but now I want to use the Indy 10 library and I got a lot of problems, even just to get a page from the Web.

This is how it goes in Indy 9:

Delphi-Quellcode:
IdHttp:=TIdHttp.Create(NIL);
Try
  Page:=IdHttp.Get(URL);
  FStringList.Text:=Page;
  .....
  .....
Finally
  IdHttp.Free;
End;
If you do this with Indy 10 then the error message will be raised:

"EidIOHandlerPropInvalid : IOHandler value is not valid"

What is the proper declaration in Indy 10 to do this?
I don't want to use the components in design time
but I want to create it in Runtime.

Greets,

Delphi Lover.
Rob
  Mit Zitat antworten Zitat
Delphi-Lover

Registriert seit: 19. Okt 2004
Ort: Amsterdam
30 Beiträge
 
Delphi 2005 Professional
 
#2

Re: How to Use Indy 10 idHTTP : IOHandler value is not valid

  Alt 15. Jun 2005, 16:11
Hello,

I did some more investigation and I see that working with the Indy 10 components is indeed quite difficult and misty to understand. The component builders wanted to "abstract" the Indy system further, but now it's so abstract that many users have only problems to use the source. On the web you'll see a lot of people telling that they deinstall the Indy 10 and go back to Indy 9. Although the Indy 10 is out now for some time, you'll find not a lot of examples on the web. especially not for Delphi. Very sad for these great components.

If anyone know how to use the Indy 10 idHTTP component in Runtime. (with IOhandlers and Intercepts...) please help us out...

So, I also used another simple way to get a page from the web, using the WinInet API. This API can work with HTTP and FTP. The interface is very C-like, but it's small and it does what I want, just get me the Webpage. (you also don't have to loop to wait for the webpage to finish...) Here is some source I found on the Web:

Delphi-Quellcode:

Uses WinInet;

procedure GetWebPage;
var
  databuffer : array[0..4095] of char;
  ResStr : string;
  hSession, hfile, hRequest: hInternet;
  dwindex,dwcodelen,datalen,dwread,dwNumber: cardinal;
  dwcode : array[1..20] of char;
  Str : pchar;
  AUrl : String;
begin
  FStringList:=TStringList.Create;

  ResStr:='';
  AUrl:='www.google.com';
  hSession:=InternetOpen('InetURL:/1.0',
                         INTERNET_OPEN_TYPE_PRECONFIG,
                         nil,
                         nil,
                         0);
  if assigned(hsession) then
  begin
    hfile:=InternetOpenUrl(
           hsession,
           pchar(AUrl),
           nil,
           0,
           INTERNET_FLAG_RELOAD,
           0);
    dwIndex := 0;
    dwCodeLen := 10;
    HttpQueryInfo(hfile,
                  HTTP_QUERY_STATUS_CODE,
                  @dwcode,
                  dwcodeLen,
                  dwIndex);
    dwNumber := sizeof(databuffer)-1;
    while (InternetReadfile(hfile,
                            @databuffer,
                            dwNumber,
                            DwRead)) do
    begin
      if dwRead =0 then break;
      databuffer[dwread]:=#0;
      Str := pchar(@databuffer);
      resStr := resStr + Str;
    end;
    if assigned(hfile) then InternetCloseHandle(hfile);
  end;
  InternetCloseHandle(hsession);

  FStringList.text := resStr;
Rob
  Mit Zitat antworten Zitat
Benutzerbild von Dani
Dani

Registriert seit: 19. Jan 2003
732 Beiträge
 
Turbo Delphi für Win32
 
#3

Re: How to Use Indy 10 idHTTP : IOHandler value is not valid

  Alt 15. Jun 2005, 16:31
Hi,

your code works fine for me (using Indy 10 for Win32). Could you tell us the value of "URL" in your case?
Dani H.
At Least I Can Say I Tried
  Mit Zitat antworten Zitat
MarkusMaier

Registriert seit: 10. Apr 2007
Ort: Traunreut
6 Beiträge
 
#4

Re: How to Use Indy 10 idHTTP : IOHandler value is not valid

  Alt 22. Okt 2008, 12:11
This line:

databuffer[dwread]:=#0;

throws an ERangeError in Delphi 2009.

Anyone has an idea how to fix this ?
  Mit Zitat antworten Zitat
Benutzerbild von Dani
Dani

Registriert seit: 19. Jan 2003
732 Beiträge
 
Turbo Delphi für Win32
 
#5

Re: How to Use Indy 10 idHTTP : IOHandler value is not valid

  Alt 22. Okt 2008, 12:44
What's the value of dwread according to the debugger when this happens?
Dani H.
At Least I Can Say I Tried
  Mit Zitat antworten Zitat
MarkusMaier

Registriert seit: 10. Apr 2007
Ort: Traunreut
6 Beiträge
 
#6

Re: How to Use Indy 10 idHTTP : IOHandler value is not valid

  Alt 23. Okt 2008, 08:37
dwRead = 8191 when this happens.

I tried to change databuffer to
databuffer : array[0..8191] of char;
- in this case, dwRead becomes 16383.

As dwRead is the number of Bytes, the problem is: Either use Ansistring(1) or change the index(2)?

1: This would only make sense if the returned value also is Ansi-kind of string - and obviosly it is no more, else this wouldn't happen..?

2: Does not make sense for me, because "Number of Bytes to read" should equal "number of Bytes read" - shouldn't it? Can #0 be used for Unicodestrings/Chars anyway?

PS: I write in english to ensure the creator of this thread could follow the discussion, too, if he wants ...
  Mit Zitat antworten Zitat
Benutzerbild von inherited
inherited

Registriert seit: 19. Dez 2005
Ort: Rosdorf
2.022 Beiträge
 
Turbo Delphi für Win32
 
#7

Re: How to Use Indy 10 idHTTP : IOHandler value is not valid

  Alt 23. Okt 2008, 11:53
Which version of Delphi do you use?
Nikolai Wyderka

SWIM SWIM HUNGRY!
Neuer Blog: hier!
  Mit Zitat antworten Zitat
MarkusMaier

Registriert seit: 10. Apr 2007
Ort: Traunreut
6 Beiträge
 
#8

Re: How to Use Indy 10 idHTTP : IOHandler value is not valid

  Alt 23. Okt 2008, 11:54
Zitat von MarkusMaier:
This line:

databuffer[dwread]:=#0;

throws an ERangeError in Delphi 2009.
Anyone has an idea how to fix this ?
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.537 Beiträge
 
Delphi 11 Alexandria
 
#9

Re: How to Use Indy 10 idHTTP : IOHandler value is not valid

  Alt 23. Okt 2008, 12:34
Maybe defining all char-/stringtypes as ANSI charset could help.
Delphi-Quellcode:
var
  databuffer : array[0..4095] of Ansichar;
  ResStr : Ansistring;
  hSession, hfile, hRequest: hInternet;
  dwindex,dwcodelen,datalen,dwread,dwNumber: cardinal;
  dwcode : array[1..20] of Ansichar;
  Str : pAnsichar;
  AUrl : AnsiString;
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
MarkusMaier

Registriert seit: 10. Apr 2007
Ort: Traunreut
6 Beiträge
 
#10

Re: How to Use Indy 10 idHTTP : IOHandler value is not valid

  Alt 23. Okt 2008, 13:11
Zitat von DeddyH:
Maybe defining all char-/stringtypes as ANSI charset could help.
It does not: Internetreadfile returns unicode data. This is the reason why this error occurs in D2009 and did not occur before anyway ... I tried this and got invalid text data ...

The following changes:

dwNumber := sizeof(databuffer) - sizeof(char);
...
dwLastItem := dwread div SizeOf(char);
databuffer[dwLastItem]:=#0;
...

do not help either as they lead to invalid data, too ...
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:35 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz