Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
Marc Weustink wrote: the following app is valid: program a; {$mode objfpc}{$h+} var p: PChar; s: String; begin p := 'abcdef'; s := p; end. An assignment is not necessarily the same as a typecast, as far as I know. They could be handled by different pieces of compiler code and have different semantics. Micha _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
Micha Nelissen wrote: Marc Weustink wrote: the following app is valid: program a; {$mode objfpc}{$h+} var p: PChar; s: String; begin p := 'abcdef'; s := p; end. An assignment is not necessarily the same as a typecast, as far as I know. They could be handled by different pieces of compiler code and have different semantics. the s := String(p) line was not in the example but was in the assembler. In this case String(p) is behaving more like a functiuon than a cast. Marc _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
ik wrote: On Jan 14, 2008 3:59 AM, wfifi [EMAIL PROTECTED] wrote: thanks ido wireshark is a great tool, i attach a log, found data is got, but Component's status not change. I've read your code again (and looked at the log), I noticed this: strstream.WriteString(String(ABuffer)) You are casting a pointer as a string... The way to convert PChar to a string is to use the function StrPas Only if you use shortstrings. When using ansistrings you can cast a PChar in to a string like: String(SomePchar) With ansistrings you seldom (or never) need StrPas Marc _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
Marc Weustink wrote: ik wrote: On Jan 14, 2008 3:59 AM, wfifi [EMAIL PROTECTED] wrote: thanks ido wireshark is a great tool, i attach a log, found data is got, but Component's status not change. I've read your code again (and looked at the log), I noticed this: strstream.WriteString(String(ABuffer)) You are casting a pointer as a string... The way to convert PChar to a string is to use the function StrPas Only if you use shortstrings. When using ansistrings you can cast a PChar in to a string like: String(SomePchar) With ansistrings you seldom (or never) need StrPas What about the length that is stored just before the memory location of ansistrings? Does PChar created with StrAlloc have this field? Luiz _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
On Mon, 14 Jan 2008, Luiz Americo Pereira Camara wrote: Marc Weustink wrote: ik wrote: On Jan 14, 2008 3:59 AM, wfifi [EMAIL PROTECTED] wrote: thanks ido wireshark is a great tool, i attach a log, found data is got, but Component's status not change. I've read your code again (and looked at the log), I noticed this: strstream.WriteString(String(ABuffer)) You are casting a pointer as a string... The way to convert PChar to a string is to use the function StrPas Only if you use shortstrings. When using ansistrings you can cast a PChar in to a string like: String(SomePchar) With ansistrings you seldom (or never) need StrPas What about the length that is stored just before the memory location of ansistrings? Does PChar created with StrAlloc have this field? No. Michael. _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
Luiz Americo Pereira Camara wrote: Marc Weustink wrote: ik wrote: On Jan 14, 2008 3:59 AM, wfifi [EMAIL PROTECTED] wrote: thanks ido wireshark is a great tool, i attach a log, found data is got, but Component's status not change. I've read your code again (and looked at the log), I noticed this: strstream.WriteString(String(ABuffer)) You are casting a pointer as a string... The way to convert PChar to a string is to use the function StrPas Only if you use shortstrings. When using ansistrings you can cast a PChar in to a string like: String(SomePchar) With ansistrings you seldom (or never) need StrPas What about the length that is stored just before the memory location of ansistrings? Does PChar created with StrAlloc have this field? It is not really a cast. The compiler adds conversion code. Marc _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
Marc Weustink wrote: You are casting a pointer as a string... The way to convert PChar to a string is to use the function StrPas Only if you use shortstrings. When using ansistrings you can cast a PChar in to a string like: String(SomePchar) With ansistrings you seldom (or never) need StrPas What about the length that is stored just before the memory location of ansistrings? Does PChar created with StrAlloc have this field? It is not really a cast. The compiler adds conversion code. I'm interested in this since currently i use StrPas to convert from PChar to AnsiString. Is this (String(PChar)) faster than StrPas? Is safe that will not change to a simple pointer cast in future? Does it copy the string content? Luiz _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
Luiz Americo Pereira Camara wrote: Marc Weustink wrote: You are casting a pointer as a string... The way to convert PChar to a string is to use the function StrPas Only if you use shortstrings. When using ansistrings you can cast a PChar in to a string like: String(SomePchar) With ansistrings you seldom (or never) need StrPas What about the length that is stored just before the memory location of ansistrings? Does PChar created with StrAlloc have this field? It is not really a cast. The compiler adds conversion code. I'm interested in this since currently i use StrPas to convert from PChar to AnsiString. that is not needed. the following app is valid: program a; {$mode objfpc}{$h+} var p: PChar; s: String; begin p := 'abcdef'; s := p; end. PChars will be autoconverted to strings The use of StrPas is from the shortstring times. Is this (String(PChar)) faster than StrPas? lets compale to assembler and comapre: # [10] s := p; leal-48(%ebp),%eax callFPC_ANSISTR_DECR_REF movl$0,-48(%ebp) movlU_P$S_P,%eax callfpc_pchar_to_ansistr movl%eax,-48(%ebp) movl-48(%ebp),%eax callFPC_ANSISTR_INCR_REF movl$U_P$S_A,%eax callFPC_ANSISTR_DECR_REF movl-48(%ebp),%eax movl%eax,U_P$S_A # [11] s := StrPas(p); leal-48(%ebp),%eax callFPC_ANSISTR_DECR_REF movl$0,-48(%ebp) leal-304(%ebp),%edx movlU_P$S_P,%eax callFPC_PCHAR_TO_SHORTSTR leal-304(%ebp),%eax callfpc_shortstr_to_ansistr movl%eax,-48(%ebp) movl-48(%ebp),%eax callFPC_ANSISTR_INCR_REF movl$U_P$S_A,%eax callFPC_ANSISTR_DECR_REF movl-48(%ebp),%eax movl%eax,U_P$S_A You see... with StrPas, the pchar is first converted to a short string. Is safe that will not change to a simple pointer cast in future? This will break compatebility. Does it copy the string content? Yes, its the same code as assigning directly # [12] s := String(p); leal-48(%ebp),%eax callFPC_ANSISTR_DECR_REF movl$0,-48(%ebp) movlU_P$S_P,%eax callfpc_pchar_to_ansistr movl%eax,-48(%ebp) movl-48(%ebp),%eax callFPC_ANSISTR_INCR_REF movl$U_P$S_A,%eax callFPC_ANSISTR_DECR_REF movl-48(%ebp),%eax movl%eax,U_P$S_A Marc _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
Marc Weustink wrote: Luiz Americo Pereira Camara wrote: Marc Weustink wrote: You are casting a pointer as a string... The way to convert PChar to a string is to use the function StrPas Only if you use shortstrings. When using ansistrings you can cast a PChar in to a string like: String(SomePchar) With ansistrings you seldom (or never) need StrPas What about the length that is stored just before the memory location of ansistrings? Does PChar created with StrAlloc have this field? It is not really a cast. The compiler adds conversion code. I'm interested in this since currently i use StrPas to convert from PChar to AnsiString. that is not needed. the following app is valid: program a; {$mode objfpc}{$h+} var p: PChar; s: String; begin p := 'abcdef'; s := p; end. PChars will be autoconverted to strings The use of StrPas is from the shortstring times. Is this (String(PChar)) faster than StrPas? lets compale to assembler and comapre: # [10] s := p; leal-48(%ebp),%eax callFPC_ANSISTR_DECR_REF movl$0,-48(%ebp) movlU_P$S_P,%eax callfpc_pchar_to_ansistr movl%eax,-48(%ebp) movl-48(%ebp),%eax callFPC_ANSISTR_INCR_REF movl$U_P$S_A,%eax callFPC_ANSISTR_DECR_REF movl-48(%ebp),%eax movl%eax,U_P$S_A # [11] s := StrPas(p); leal-48(%ebp),%eax callFPC_ANSISTR_DECR_REF movl$0,-48(%ebp) leal-304(%ebp),%edx movlU_P$S_P,%eax callFPC_PCHAR_TO_SHORTSTR leal-304(%ebp),%eax callfpc_shortstr_to_ansistr movl%eax,-48(%ebp) movl-48(%ebp),%eax callFPC_ANSISTR_INCR_REF movl$U_P$S_A,%eax callFPC_ANSISTR_DECR_REF movl-48(%ebp),%eax movl%eax,U_P$S_A You see... with StrPas, the pchar is first converted to a short string. Is safe that will not change to a simple pointer cast in future? This will break compatebility. Does it copy the string content? Yes, its the same code as assigning directly # [12] s := String(p); leal-48(%ebp),%eax callFPC_ANSISTR_DECR_REF movl$0,-48(%ebp) movlU_P$S_P,%eax callfpc_pchar_to_ansistr movl%eax,-48(%ebp) movl-48(%ebp),%eax callFPC_ANSISTR_INCR_REF movl$U_P$S_A,%eax callFPC_ANSISTR_DECR_REF movl-48(%ebp),%eax movl%eax,U_P$S_A Thanks. This info is useful Luiz _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
[lazarus] why sometime TLHTTPClientComponent can not get data?
some url can get data(example: http://www.google.com/ ), some others can't(example: http://anime.xunlei.com/Book/category/610), all url can browsered by ie or firefox. how debug can find the reasons? partly my code: procedure TFormMain.MenuItemNewStoryClick(Sender: TObject); var Urlstr: String; aHost, aURI: string; aPort: Word; node: TTreeNode; begin Urlstr := InputBox('Input Comic Story Url', 'Please input comic story url', 'http://anime.xunlei.com/Book/category/610'); if (Urlstr'') and (Urlstr'http://') then begin HTTPClient.Disconnect(); strstream:= TStringStream.Create(''); DecomposeURL(Urlstr, aHost, aURI, aPort); HTTPClient.Host := aHost; HTTPClient.URI := aURI; HTTPClient.Port := aPort; HTTPClient.SendRequest; StatusBar.SimpleText := 'Connect...'; end else //ShowMessage('Invalid Url'); end; function TFormMain.HttpClientInput(ASocket: TLHTTPClientSocket; ABuffer: pchar; ASize: integer): integer; var oldLength: integer; begin StatusBar.SimpleText := 'input...'; strstream.WriteString(String(ABuffer)); StatusBar.SimpleText := IntToStr(ASize) + '...'; Result := ASize; // tell the http buffer we read it all end;
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
Do you have LHTTPClientError event ? If not, please make sure you have and try to show any given error... BTW, do you use a sniffer to see how your request is transferring ? Ido On Jan 13, 2008 10:55 AM, wfifi [EMAIL PROTECTED] wrote: some url can get data(example: http://www.google.com/ ), some others can't(example: http://anime.xunlei.com/Book/category/610 ), all url can browsered by ie or firefox. how debug can find the reasons? partly my code: procedure TFormMain.MenuItemNewStoryClick(Sender: TObject); var Urlstr: String; aHost, aURI: string; aPort: Word; node: TTreeNode; begin Urlstr := InputBox('Input Comic Story Url', 'Please input comic story url', 'http://anime.xunlei.com/Book/category/610' ); if (Urlstr'') and (Urlstr'http://') then begin HTTPClient.Disconnect(); strstream:= TStringStream.Create(''); DecomposeURL(Urlstr, aHost, aURI, aPort); HTTPClient.Host := aHost; HTTPClient.URI := aURI; HTTPClient.Port := aPort; HTTPClient.SendRequest; StatusBar.SimpleText := 'Connect...'; end else //ShowMessage('Invalid Url'); end; function TFormMain.HttpClientInput(ASocket: TLHTTPClientSocket; ABuffer: pchar; ASize: integer): integer; var oldLength: integer; begin StatusBar.SimpleText := 'input...'; strstream.WriteString(String(ABuffer)); StatusBar.SimpleText := IntToStr(ASize) + '...'; Result := ASize; // tell the http buffer we read it all end; -- http://ik.homelinux.org/ _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
yes, i have a LHTTPClientError event. no error occurred, it looks like program called HTTPClientProcessHeaders, then no data receive. can suggest some sniffer tools(for win xp) procedure TFormMain.HTTPClientError(const msg: string; aSocket: TLSocket); begin StatusBar.SimpleText := 'Error.'; MessageDlg(msg, mtError, [mbOK], 0); end; procedure TFormMain.HTTPClientProcessHeaders(ASocket: TLHTTPClientSocket); begin StatusBar.SimpleText := 'Response: ' + IntToStr(HTTPStatusCodes[ASocket.ResponseStatus]) + ' ' + ASocket.ResponseReason + ', data...'; end; 2008/1/13, ik [EMAIL PROTECTED]: Do you have LHTTPClientError event ? If not, please make sure you have and try to show any given error... BTW, do you use a sniffer to see how your request is transferring ? Ido On Jan 13, 2008 10:55 AM, wfifi [EMAIL PROTECTED] wrote: some url can get data(example: http://www.google.com/ ), some others can't(example: http://anime.xunlei.com/Book/category/610 ), all url can browsered by ie or firefox. how debug can find the reasons? partly my code: procedure TFormMain.MenuItemNewStoryClick(Sender: TObject); var Urlstr: String; aHost, aURI: string; aPort: Word; node: TTreeNode; begin Urlstr := InputBox('Input Comic Story Url', 'Please input comic story url', 'http://anime.xunlei.com/Book/category/610' ); if (Urlstr'') and (Urlstr'http://') then begin HTTPClient.Disconnect(); strstream:= TStringStream.Create(''); DecomposeURL(Urlstr, aHost, aURI, aPort); HTTPClient.Host := aHost; HTTPClient.URI := aURI; HTTPClient.Port := aPort; HTTPClient.SendRequest; StatusBar.SimpleText := 'Connect...'; end else //ShowMessage('Invalid Url'); end; function TFormMain.HttpClientInput(ASocket: TLHTTPClientSocket; ABuffer: pchar; ASize: integer): integer; var oldLength: integer; begin StatusBar.SimpleText := 'input...'; strstream.WriteString(String(ABuffer)); StatusBar.SimpleText := IntToStr(ASize) + '...'; Result := ASize; // tell the http buffer we read it all end; -- http://ik.homelinux.org/ _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
On Jan 13, 2008 1:26 PM, wfifi [EMAIL PROTECTED] wrote: yes, i have a LHTTPClientError event. no error occurred, it looks like program called HTTPClientProcessHeaders, then no data receive. Please look at the headers, it can give you error number inside the header, like 500, 510 or even a 302 (redirect) etc.. can suggest some sniffer tools(for win xp) amm.. wrireshark http://www.wireshark.org/ Or change Windows to some normal OS like Linux or Free/Desktop BSD ;) procedure TFormMain.HTTPClientError (const msg: string; aSocket: TLSocket); begin StatusBar.SimpleText := 'Error.'; MessageDlg(msg, mtError, [mbOK], 0); end; procedure TFormMain.HTTPClientProcessHeaders(ASocket: TLHTTPClientSocket); begin StatusBar.SimpleText := 'Response: ' + IntToStr(HTTPStatusCodes[ASocket.ResponseStatus]) + ' ' + ASocket.ResponseReason + ', data...'; end; 2008/1/13, ik [EMAIL PROTECTED]: Do you have LHTTPClientError event ? If not, please make sure you have and try to show any given error... BTW, do you use a sniffer to see how your request is transferring ? Ido On Jan 13, 2008 10:55 AM, wfifi [EMAIL PROTECTED] wrote: some url can get data(example: http://www.google.com/ ), some others can't(example: http://anime.xunlei.com/Book/category/610 ), all url can browsered by ie or firefox. how debug can find the reasons? partly my code: procedure TFormMain.MenuItemNewStoryClick(Sender: TObject); var Urlstr: String; aHost, aURI: string; aPort: Word; node: TTreeNode; begin Urlstr := InputBox('Input Comic Story Url', 'Please input comic story url', 'http://anime.xunlei.com/Book/category/610' ); if (Urlstr'') and (Urlstr'http://') then begin HTTPClient.Disconnect(); strstream:= TStringStream.Create(''); DecomposeURL(Urlstr, aHost, aURI, aPort); HTTPClient.Host := aHost; HTTPClient.URI := aURI; HTTPClient.Port := aPort; HTTPClient.SendRequest; StatusBar.SimpleText := 'Connect...'; end else //ShowMessage('Invalid Url'); end; function TFormMain.HttpClientInput(ASocket: TLHTTPClientSocket; ABuffer: pchar; ASize: integer): integer; var oldLength: integer; begin StatusBar.SimpleText := 'input...'; strstream.WriteString(String(ABuffer)); StatusBar.SimpleText := IntToStr(ASize) + '...'; Result := ASize; // tell the http buffer we read it all end; -- http://ik.homelinux.org/ _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives -- http://ik.homelinux.org/ _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
I can't see the content, and from quick googeling, i see that it's a known communication sniffer in china / In tcpdump (when using unix) or wireshark, you can see also the content that you send and receive, so it's easier to know what's going on. Ido On Jan 13, 2008 1:46 PM, wfifi [EMAIL PROTECTED] wrote: 200 ok,i use GUNiffer GUNiffer.exe /t /u url http://anime.xunlei.com/Book/category/610 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 -S bytes= 60 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 -S--A- bytes= 48 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 ---PA- bytes= 99 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 F--PA- bytes= 215 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 2008/1/13, ik [EMAIL PROTECTED]: On Jan 13, 2008 1:26 PM, wfifi [EMAIL PROTECTED] wrote: yes, i have a LHTTPClientError event. no error occurred, it looks like program called HTTPClientProcessHeaders, then no data receive. Please look at the headers, it can give you error number inside the header, like 500, 510 or even a 302 (redirect) etc.. can suggest some sniffer tools(for win xp) amm.. wrireshark http://www.wireshark.org/ Or change Windows to some normal OS like Linux or Free/Desktop BSD ;) procedure TFormMain.HTTPClientError (const msg: string; aSocket: TLSocket); begin StatusBar.SimpleText := 'Error.'; MessageDlg(msg, mtError, [mbOK], 0); end; procedure TFormMain.HTTPClientProcessHeaders(ASocket: TLHTTPClientSocket); begin StatusBar.SimpleText := 'Response: ' + IntToStr(HTTPStatusCodes[ASocket.ResponseStatus]) + ' ' + ASocket.ResponseReason + ', data...'; end; 2008/1/13, ik [EMAIL PROTECTED]: Do you have LHTTPClientError event ? If not, please make sure you have and try to show any given error... BTW, do you use a sniffer to see how your request is transferring ? Ido On Jan 13, 2008 10:55 AM, wfifi [EMAIL PROTECTED] wrote: some url can get data(example: http://www.google.com/ ), some others can't(example: http://anime.xunlei.com/Book/category/610 ), all url can browsered by ie or firefox. how debug can find the reasons? partly my code: procedure TFormMain.MenuItemNewStoryClick(Sender: TObject); var Urlstr: String; aHost, aURI: string; aPort: Word; node: TTreeNode; begin Urlstr := InputBox('Input Comic Story Url', 'Please input comic story url', ' http://anime.xunlei.com/Book/category/610' ); if (Urlstr'') and (Urlstr'http://') then begin HTTPClient.Disconnect(); strstream:= TStringStream.Create(''); DecomposeURL(Urlstr, aHost, aURI, aPort); HTTPClient.Host := aHost; HTTPClient.URI:= aURI; HTTPClient.Port := aPort; HTTPClient.SendRequest; StatusBar.SimpleText := 'Connect...'; end else //ShowMessage('Invalid Url'); end; function TFormMain.HttpClientInput(ASocket: TLHTTPClientSocket; ABuffer: pchar; ASize: integer): integer; var oldLength: integer; begin StatusBar.SimpleText := 'input...'; strstream.WriteString(String(ABuffer)); StatusBar.SimpleText := IntToStr(ASize) + '...'; Result := ASize; // tell the http buffer we read it all end; -- http://ik.homelinux.org/
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
200 ok,i use GUNiffer GUNiffer.exe /t /u url http://anime.xunlei.com/Book/category/610 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 -S bytes= 60 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 -S--A- bytes= 48 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 ---PA- bytes= 99 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 A- bytes=1300 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 TCP 58.251.57.69: 80 - 192.168.1.100: 3617 TTL= 52 F--PA- bytes= 215 TCP192.168.1.100: 3617 - 58.251.57.69: 80 TTL=128 A- bytes= 40 2008/1/13, ik [EMAIL PROTECTED]: On Jan 13, 2008 1:26 PM, wfifi [EMAIL PROTECTED] wrote: yes, i have a LHTTPClientError event. no error occurred, it looks like program called HTTPClientProcessHeaders, then no data receive. Please look at the headers, it can give you error number inside the header, like 500, 510 or even a 302 (redirect) etc.. can suggest some sniffer tools(for win xp) amm.. wrireshark http://www.wireshark.org/ Or change Windows to some normal OS like Linux or Free/Desktop BSD ;) procedure TFormMain.HTTPClientError (const msg: string; aSocket: TLSocket); begin StatusBar.SimpleText := 'Error.'; MessageDlg(msg, mtError, [mbOK], 0); end; procedure TFormMain.HTTPClientProcessHeaders(ASocket: TLHTTPClientSocket); begin StatusBar.SimpleText := 'Response: ' + IntToStr(HTTPStatusCodes[ASocket.ResponseStatus]) + ' ' + ASocket.ResponseReason + ', data...'; end; 2008/1/13, ik [EMAIL PROTECTED]: Do you have LHTTPClientError event ? If not, please make sure you have and try to show any given error... BTW, do you use a sniffer to see how your request is transferring ? Ido On Jan 13, 2008 10:55 AM, wfifi [EMAIL PROTECTED] wrote: some url can get data(example: http://www.google.com/ ), some others can't(example: http://anime.xunlei.com/Book/category/610 ), all url can browsered by ie or firefox. how debug can find the reasons? partly my code: procedure TFormMain.MenuItemNewStoryClick(Sender: TObject); var Urlstr: String; aHost, aURI: string; aPort: Word; node: TTreeNode; begin Urlstr := InputBox('Input Comic Story Url', 'Please input comic story url', 'http://anime.xunlei.com/Book/category/610' ); if (Urlstr'') and (Urlstr'http://') then begin HTTPClient.Disconnect(); strstream:= TStringStream.Create(''); DecomposeURL(Urlstr, aHost, aURI, aPort); HTTPClient.Host := aHost; HTTPClient.URI := aURI; HTTPClient.Port := aPort; HTTPClient.SendRequest; StatusBar.SimpleText := 'Connect...'; end else //ShowMessage('Invalid Url'); end; function TFormMain.HttpClientInput(ASocket: TLHTTPClientSocket; ABuffer: pchar; ASize: integer): integer; var oldLength: integer; begin StatusBar.SimpleText := 'input...'; strstream.WriteString(String(ABuffer)); StatusBar.SimpleText := IntToStr(ASize) + '...'; Result := ASize; // tell the http buffer we read it all end; -- http://ik.homelinux.org/ _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives -- http://ik.homelinux.org/ _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
thanks ido wireshark is a great tool, i attach a log, found data is got, but Component's status not change. 2008/1/13, ik [EMAIL PROTECTED]: I can't see the content, and from quick googeling, i see that it's a known communication sniffer in china / In tcpdump (when using unix) or wireshark, you can see also the content that you send and receive, so it's easier to know what's going on. Ido tt.pcap Description: Binary data
Re: [lazarus] why sometime TLHTTPClientComponent can not get data?
On Jan 14, 2008 3:59 AM, wfifi [EMAIL PROTECTED] wrote: thanks ido wireshark is a great tool, i attach a log, found data is got, but Component's status not change. I've read your code again (and looked at the log), I noticed this: strstream.WriteString(String(ABuffer)) You are casting a pointer as a string... The way to convert PChar to a string is to use the function StrPas I believe that it will solve the problem. Ido 2008/1/13, ik [EMAIL PROTECTED] : I can't see the content, and from quick googeling, i see that it's a known communication sniffer in china / In tcpdump (when using unix) or wireshark, you can see also the content that you send and receive, so it's easier to know what's going on. Ido -- http://ik.homelinux.org/ _ To unsubscribe: mail [EMAIL PROTECTED] with unsubscribe as the Subject archives at http://www.lazarus.freepascal.org/mailarchives