Twebclie enhancement

Post Reply
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Twebclie enhancement

Post by Davide »

The modified method above allows retrieving a page from a server with shared IP hosting (but works even with static IP servers) if cPageName starts with "http://", otherwise it works as before (for compatibility reasons).

Code: Select all | Expand

   METHOD GetPage( cPageName ) INLINE ;   
          ::oSocket:SendData( "GET "+IIf(Upper(Left(cPageName,7))="HTTP://",;
                              cPageName + " HTTP/1.0" + CRLF + "host: " + SubStr(cPageName,8,AT("/",SubStr(cPageName,8)+"/")-1),;
                              "/" + cPageName + " HTTP/1.0") + CRLF + CRLF )


Antonio, could you please update the standard lib ?
Hi,
Davide
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Davide,

Updated, thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Post by Davide »

This one is better (correct HTTP/1.1 syntax and user-agent declaration)
Hi,
Davide

Code: Select all | Expand

   METHOD GetPage( cPageName ) INLINE ;    // *GD*
          ::oSocket:SendData( "GET /"+IIf(Upper(Left(cPageName,7))="HTTP://",;
                                    SubStr(cPageName,AT("/",SubStr(cPageName,8)+"/")+8) + " HTTP/1.1" + CRLF +;
                                           "Host: " + SubStr(cPageName,8,AT("/",SubStr(cPageName,8)+"/")-1) + CRLF +;
                                           "User-Agent: TWebClient/2008.09.03",;
                                    cPageName + " HTTP/1.0") + CRLF + CRLF )
User avatar
Antonio Linares
Site Admin
Posts: 42519
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

Post by Antonio Linares »

Davide,

Updated, thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply