Witam
zrobilem klijenta do komunikacji z serwerem HTTP na komponencie INDY IdHTTP. Komponent ten ma metodę POST która wymaga 3 argumentów czyli :
procedure Post(URL: string; const Source: TStrings; const AResponseContent: TStream); overload;
ja zrobilem to tak
idhttp1.Post('http://xxx.pl',nadaj,odbierz);
z tym że nadaj jest typu TStringList a nie TStrings bo wyskakiwały mi błędy...
jak inicjuje obiekt nadaj i przypisuje mu wartość w sposób
nadaj:=TStringList.Create;
nadaj.Add('costamcostam');
idhttp1.Post('http://xxx.pl',nadaj,odbierz);
to potem na analizatorze sieci okazuje się że ciąg nadaj jest o 2 jednostki dłuższy niż wynikałoby to z długosci ciagu 'costamcostam' (czyli powinno być 12 a jest 14)
tak wyglądają nagłowki z protkokołów HTTP podsłuchane za pomoca ETHEREAL'a:
POST / HTTP/1.0
Host: xxx.pl
Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1
Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0
Accept-Language: pl-PL,pl;q=0.9,en;q=0.8
Referer: http://www.xxx.pl/
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; pl) Opera 9.21
Connection: Keep-Alive, TE
Content-Length: 86 // 86 !!! a powinno byc 84 !!//
Cookie: PHPSESSID=1750285f62ae6cc9818b460544983d32
PHPSESSID=1750285f62ae6cc9818b460544983d32&getemail=Utw%F3rz+tymczasowy+adres+e-mail
HTTP/1.1 200 OK
Date: Tue, 24 Jul 2007 12:49:59 GMT
Server: Apache/2
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Connection: close
Content-Type: text/html
a tak powinny wyglądać :
POST / HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; pl) Opera 9.21
Host: www.xxx.pl
Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Accept-Language: pl-PL,pl;q=0.9,en;q=0.8
Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1
Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0
Cookie: PHPSESSID=c7dd16c30e7f4cdeaaf608471451035c
Cookie2: $Version=1
Connection: Keep-Alive, TE
TE: deflate, gzip, chunked, identity, trailers
Content-Length: 84 //tak powinno być czyli 84//
Content-Type: application/x-www-form-urlencoded
PHPSESSID=c7dd16c30e7f4cdeaaf608471451035c&getemail=Utw%F3rz+tymczasowy+adres+e-mailHTTP/1.1 302 Found
Date: Tue, 24 Jul 2007 13:19:10 GMT
Server: Apache/2
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Location: http://www.xxx.pl/
Keep-Alive: timeout=2, max=50
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
0
funkcja trim tez nie pomaga nie pomaga
<delphi>
nadaj:=TStringList.Create;
nadaj.Add(Trim('costamcostam'));
idhttp1.Post('http://xxx.pl',nadaj,odbierz);
Proszę o jakieś sugestie LUB?I UWAGI
</delphi>