Article View: borland.public.cppbuilder.internet.socket
Article #4461retrieve a simple web page by knowing its URL
From: Stefano Bonifazi
Date: Wed, 09 Feb 2005 09:26
Date: Wed, 09 Feb 2005 09:26
46 lines
2872 bytes
2872 bytes
Hi all!
My task should be simple, but for some reason it does not work.
I have to retrieve a simple web page by knowing its URL ... a task that I
managed to accomplish several times, but with this site something goes
wrong:
I can post the URL, I hope it's not against some Newsgroup rule:
http://www14.brinkster.com/stefboombastic/default.htm it's only a my simple
htm test page on a server that offers free web space.
I set the Host property of my TClientSocket (working as a normal
ctNonBlocking) to "www14.brinkster.com" it's port property to 80, I have a
simple button to connect (simply set the active property to true) and a
simple button to get the page with the following:
hostent *pHost = gethostbyname("www14.brinkster.com");
AnsiString IP="";
if( pHost )
{
IP = inet_ntoa( *( (in_addr *)pHost->h_addr ) );
}
AnsiString Request="GET /stefboombastic/default.htm HTTP/1.1\r\n"
"Accept: image/gif, image/x-xbitmap, image/jpeg,
image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, */*\r\n"
"Accept-Language: it\r\n"
"Accept-Encoding: gzip, deflate\r\n"
"Host: "+IP+"\r\n"
"Connection: Keep-Alive\r\n"
"\r\n";
SDBLogClientSocket->Socket->SendText(Request);
In the OnRead event Handler I simply copy the received text on a TMemo ...
It connects fine but then I receive the classical HTTP 404 error "The page
cannot be found".
They use IIS, and the strange thing is that on my local IIS (changing
www14.brinkster.com with localhost) my code works!!
The indy IdHTTP component works fine with its Get method in retrieving that
page as well as The fastnet NMHTTP (but as said in my previous newsgroup
thread I cannot use them!:( )
Can anyone help me?
Thank You very much in advance!
Stefano B.
Technical Details
Message-ID:
<4209d747@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.agarik.com!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,474753b63a76f917,start X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Stefano Bonifazi" <stefboombastic@email.it> Newsgroups: borland.public.cppbuilder.internet.socket Subject: retrieve a simple web page by knowing its URL Date: Wed, 9 Feb 2005 10:26:31 +0100 Lines: 48 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 212.141.199.211 Message-ID: <4209d747@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1107941191 212.141.199.211 (9 Feb 2005 01:26:31 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.agarik.com!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail