[ptt-users] Problem with HTTPProtocol.connect(1)

Geoff Meakin geoffm at gamesys.co.uk
Tue Nov 21 14:25:01 PST 2006


I wrote a routine to handle some of our redirect problems. It may or may not be of use to you... (see the base url checking in the refreshcheck section)


    def getPage( self, url, params=None ):
        self.log(1,"Get  "+url+" with params="+str(params))
        while url!='':
           #print str(url)
           if params==None:
               resp=self.get(url)
           else:
               resp=self.get(url, params)
           locationcheck=str(resp.getParameterValue('Location'))
           if locationcheck==None or locationcheck=='None':

               # Check for <META HTTP-EQUIV=Refresh CONTENT="0; URL=home.do">

               #self.log(1,"  urlcheck> "+str(resp))
               refreshcheck=re.match('.*<META\ +HTTP-EQUIV=Refresh\ +CONTENT=.*URL=([^\"\']*)',str(resp),re.IGNORECASE)
               if refreshcheck==None:
                   url=''
               else:
                   #self.log(1,"  refreshcheck> "+str(refreshcheck.group(0)))
                   try:
                       nurl=refreshcheck.group(1)
                       nurl=nurl.lstrip().rstrip()
                   except:
                       nurl=''
                   #self.log(1,"  ===> "+nurl)
                   if re.match('^https?://',nurl,re.IGNORECASE):
                       url=nurl
                   else:
                       if string.find(nurl,'/')==0:
                           url=re.sub('^([^\.]*\.[^\/]*)\/.*','\\1',url)+nurl
                       else:
                           url=re.sub('/[^/]*$','/',url)+nurl
                   self.log(2,"  ---> "+url)

           else:
               url=locationcheck
               self.log(1,"  ---> "+locationcheck)
        return resp


Cheers
-Geoff


-----Original Message-----
From: users-bounces at lists.pushtotest.com on behalf of Aaron Romeo
Sent: Tue 21/11/2006 20:02
To: TestMaker users list
Subject: RE: [ptt-users] Problem with HTTPProtocol.connect(1)
 
OK Frank...

Any idea how people have resolved this in the past?  Will I be forced to
have to handle the redirects manually?

Thanks,
Aaron.

-----Original Message-----
From: users-bounces at lists.pushtotest.com
[mailto:users-bounces at lists.pushtotest.com] On Behalf Of Frank Cohen
Sent: Tuesday, November 21, 2006 3:00 PM
To: TestMaker users list
Subject: Re: [ptt-users] Problem with HTTPProtocol.connect(1)

Hi Aaron: I've taken a look at this in the past and found that the  
browsers handle redirects differently.



On Nov 21, 2006, at 8:11 AM, Aaron Romeo wrote:

> Hello,
>
> I have a problem with the HTTPProtocol.connect(1) function.
>
> The website I am testing uses a path to redirect.  For example, if  
> the base
> URL is www.myurl.com, the first page might be www.myurl.com/ 
> default.html.
> On this page, I have another link that links me to second.html.   
> The browser
> can identify that I am referring to www.myurl.com/second.html.   
> However
> TestMaker doesn't contain my base and host URL anymore.  It has  
> also lost
> the protocol.
>
> Can someone tell me how I can get around this?  I would really like  
> to have
> TestMaker handle my redirects for me.
>
> Thanks,
> --
> Aaron Romeo
> _______________________________________________
> Users mailing list
> Users at lists.pushtotest.com
> http://lists.pushtotest.com/mailman/listinfo/users
>

_______________________________________________
Users mailing list
Users at lists.pushtotest.com
http://lists.pushtotest.com/mailman/listinfo/users
_______________________________________________
Users mailing list
Users at lists.pushtotest.com
http://lists.pushtotest.com/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cake.pushtotest.com/pipermail/users/attachments/20061121/cd2482e9/attachment.htm


More information about the Users mailing list