Re: [twsocket] HttpClient download and Progress Bar
Le 09/01/2011 16:08, Jean-Paul Passama a écrit : Le 09/01/2011 15:49, Arno Garrels a écrit : Jean-Paul Passama wrote: Hi, I'm trying to have a progress bar working during a file download by HttpClient.Get (and HttpClient.RcvdStream). I've seen the OnDocData that seems to receive the length of data downloaded. Unfortunaly, the data length isn't really the size of the piece of file downloaded because the packed received include the HTTP protocol and the data. Is a way to know : - the size of the entire file (before starting the download) Quoted from http://www.rfc-editor.org/rfc/rfc2068.txt: "An HTTP/1.1 server may also establish persistent connections with HTTP/1.0 clients upon receipt of a Keep-Alive connection token. However, a persistent connection with an HTTP/1.0 client cannot make use of the chunked transfer-coding, and therefore MUST use a Content-Length for marking the ending boundary of each message." So it should be possible to force the server to send a content-length header. In event OnDocBegin property ContentLength should return that value. In the Event OnDocBegin , no such property (ContentLength) : procedure TMyForm.HttpCli1DocBegin(Sender: TObject); And THttpClient doesn't have this property. So where I could retrieve this property from ? Thank you JP Sorry for that message, I tried and it works : procedure TClubFTP.HttpCli1DocBegin(Sender: TObject); var x : integer; begin x := (Sender as THttpCli).ContentLength; if (x <> -1) and (SizeFile = 0) then begin SizeFile := x; end; end; The ProgressBar works with RcvdStream.Position procedure TClubFTP.HttpCli1DocData(Sender: TObject; Buffer: Pointer; Len: Integer); var x : longint; begin x := HttpCli1.RcvdStream.Position * 100 div SizeFile; if x > 0 then PB.Position := x; end; Thank you JP -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] HttpClient download and Progress Bar
Le 09/01/2011 15:49, Arno Garrels a écrit : Jean-Paul Passama wrote: Hi, I'm trying to have a progress bar working during a file download by HttpClient.Get (and HttpClient.RcvdStream). I've seen the OnDocData that seems to receive the length of data downloaded. Unfortunaly, the data length isn't really the size of the piece of file downloaded because the packed received include the HTTP protocol and the data. Is a way to know : - the size of the entire file (before starting the download) Quoted from http://www.rfc-editor.org/rfc/rfc2068.txt: "An HTTP/1.1 server may also establish persistent connections with HTTP/1.0 clients upon receipt of a Keep-Alive connection token. However, a persistent connection with an HTTP/1.0 client cannot make use of the chunked transfer-coding, and therefore MUST use a Content-Length for marking the ending boundary of each message." So it should be possible to force the server to send a content-length header. In event OnDocBegin property ContentLength should return that value. In the Event OnDocBegin , no such property (ContentLength) : procedure TMyForm.HttpCli1DocBegin(Sender: TObject); And THttpClient doesn't have this property. So where I could retrieve this property from ? Thank you JP -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] HttpClient download and Progress Bar
Jean-Paul Passama wrote: > Hi, > > I'm trying to have a progress bar working during a file download by > HttpClient.Get (and HttpClient.RcvdStream). > > I've seen the OnDocData that seems to receive the length of data > downloaded. Unfortunaly, the data length isn't really the size of the > piece of file downloaded because the packed received include the HTTP > protocol and the data. > > Is a way to know : > - the size of the entire file (before starting the download) Quoted from http://www.rfc-editor.org/rfc/rfc2068.txt: "An HTTP/1.1 server may also establish persistent connections with HTTP/1.0 clients upon receipt of a Keep-Alive connection token. However, a persistent connection with an HTTP/1.0 client cannot make use of the chunked transfer-coding, and therefore MUST use a Content-Length for marking the ending boundary of each message." So it should be possible to force the server to send a content-length header. In event OnDocBegin property ContentLength should return that value. -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] HttpServer UTF8 problem
Busai Péter wrote: >> Hi! >> >> I'm trying to port my webapplication to Delphi XE unicode compiler. >> I have problem to encode accented text in RowDataGetter. >> In recent nonunicode version I just made conversion like: >> Tagdata.Add('key', AnsiToUTF8(some_accented_value)) >> In Delphi XE I tried Tagdata.Add('key', >> UTF8Encode(some_accented_value)), but the result is not UTF8 encoded. >> I think it is converted back to Unicode because Add accepts String >> parameters. Yes, TStringIndex stores strings in a TStringList. >> Where and how should I do the conversion? Unless some utility functions are not changed to support more than system's ANSI codepage it's not possible. These functions could get overloaded versions that take a CodePage argument. -- Arno Garrels -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
[twsocket] HttpServer UTF8 problem
Hi! I'm trying to port my webapplication to Delphi XE unicode compiler. I have problem to encode accented text in RowDataGetter. In recent nonunicode version I just made conversion like: Tagdata.Add('key', AnsiToUTF8(some_accented_value)) In Delphi XE I tried Tagdata.Add('key', UTF8Encode(some_accented_value)), but the result is not UTF8 encoded. I think it is converted back to Unicode because Add accepts String parameters. Where and how should I do the conversion? Thanks Peter A(z) kimenő üzenetben nem található vírus. Ellenőrizte: AVG - www.avg.com Verzió: 9.0.872 / Vírus adatbázis: 271.1.1/3368 - Kiadás dátuma: 01/08/11 20:34:00 -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
[twsocket] HttpClient download and Progress Bar
Hi, I'm trying to have a progress bar working during a file download by HttpClient.Get (and HttpClient.RcvdStream). I've seen the OnDocData that seems to receive the length of data downloaded. Unfortunaly, the data length isn't really the size of the piece of file downloaded because the packed received include the HTTP protocol and the data. Is a way to know : - the size of the entire file (before starting the download) - the size of all data (I mean the size of the file piece received and not the size of the entire packet received). Thanks JP -- To unsubscribe or change your settings for TWSocket mailing list please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be