HTMLViewer and redirects

Its seems that when using the HTMLViewer control, if the URL you request to open contains a redirect, you do not get a DocumentComplete event for the page you are redirected to, only for the page you requested. Am I correct and if so is this a bug?

Bump

Can you post a URL to test against and I will take a look when I get to work tonight… Also, what OS(es) and Xojo version(s) [why does this always have to be asked, it should just automatically be posted when asking for confirmation]

www.yahoo.com

OSX, Mavericks, Xojo 2014 r2.1

[quote=136897:@Mike Charlesworth]www.yahoo.com

OSX, Mavericks, Xojo 2014 r2.1[/quote]

I don’t know what Yahoo is doing exactly, but it is not pure blue.

I loadURL http://yahoo.com
This displays https://fr.yahoo.com/?p=us
Document Complete reports as url https://s.yimg.com/rq/darla/2-8-4/html/r-csc.html

If I put https://s.yimg.com/rq/darla/2-8-4/html/r-csc.html in a browser, I get “undefined document”.

In the UK you probably get something else pertaining to your region.

I think this looks less like a Xojo bug than some hackish trick on Yahoo part to make their pesky geolocalization work.

[quote=136904:@Michel Bujardet]I don’t know what Yahoo is doing exactly, but it is not pure blue.

I loadURL http://yahoo.com
This displays https://fr.yahoo.com/?p=us
Document Complete reports as url https://s.yimg.com/rq/darla/2-8-4/html/r-csc.html

If I put https://s.yimg.com/rq/darla/2-8-4/html/r-csc.html in a browser, I get “undefined document”.

In the UK you probably get something else pertaining to your region.

I think this looks less like a Xojo bug than some hackish trick on Yahoo part to make their pesky geolocalization work.[/quote]
I think it is a bug. Try other sites, same type of issue

I tried again with a page I built with HTML Refresh.
http://fontmenu.com/xojo/refresh.html

It simply redirects this way :

<META HTTP-EQUIV="REFRESH" CONTENT="2;URL=http://www.matchfonts.com/index.html">

The redirect takes forever instead of the 2 seconds set in the HTML, but when the redirect completes, url does report the correct landing one. But the extremely long delay is not normal at all. In a browser, the redirect occurs in a blink.

[quote=137070:@Michel Bujardet]I tried again with a page I built with HTML Refresh.
http://fontmenu.com/xojo/refresh.html

It simply redirects this way :

<META HTTP-EQUIV="REFRESH" CONTENT="2;URL=http://www.matchfonts.com/index.html">

The redirect takes forever instead of the 2 seconds set in the HTML, but when the redirect completes, url does report the correct landing one. But the extremely long delay is not normal at all. In a browser, the redirect occurs in a blink.[/quote]
That’s not the type of redirect that yahoo is using. They are likely returning a 301 or 302 http status code with a URLs in the header to redirect to. The only way I can think of to follow this type of redirect is to use an http socket to request the URL and follow the redirects using the HeadersReceived event until you get back an actual page. Make sure you set the user-agent header in the httpsocket and in the htmlviewer because some sights reject requests if they don’t think you are a browser (or redirect you somewhere else).

[quote=137091:@Greg O’Lone]That’s not the type of redirect that yahoo is using. They are likely returning a 301 or 302 http status code with a URLs in the header to redirect to. The only way I can think of to follow this type of redirect is to use an http socket to request the URL and follow the redirects using the HeadersReceived event until you get back an actual page. Make sure you set the user-agent header in the httpsocket and in the htmlviewer because some sights reject requests if they don’t think you are a browser (or redirect you somewhere else).[/quote]thanks Greg, I am talking about the redirects you are talking about, rewrites essentially. I will try your solution. Does the user agent matter, I.e. Do I set it as safari or the like?

The user agent may matter. Sites will sometimes deliver different content based on the browser that connects.

yeah, they are returning 301

[code]telnet yahoo.com 80
Trying 98.138.253.109…
Connected to yahoo.com.
Escape character is ‘^]’.
GET / HTTP/1.1
Host: yahoo.com

HTTP/1.1 301 Redirect
Date: Wed, 22 Oct 2014 10:50:39 GMT
Via: http/1.1 ir22.fp.ne1.yahoo.com (ApacheTrafficServer)
Server: ATS
Location: https://www.yahoo.com/
Content-Type: text/html
Content-Language: en
Connection: keep-alive
Content-Length: 1450

Yahoo html { height: 100%; } body { background: #fafafc url(https://s.yimg.com/nn/img/sad-panda-201402200631.png) 50% 50%; background-size: cover; height: 100%; text-align: center; font: 300 18px "helvetica neue", helvetica, verdana, tahoma, arial, sans-serif; } table { height: 100%; width: 100%; table-layout: fixed; border-collapse: collapse; border-spacing: 0; border: none; } h1 { font-size: 42px; font-weight: 400; color: #400090; } p { color: #1A1A1A; } #message-1 { font-weight: bold; margin: 0; } #message-2 { display: inline-block; *display: inline; zoom: 1; max-width: 17em; _width: 17em; }
Yahoo Logo

Will be right back...

Thank you for your patience.

Our engineers are working quickly to resolve the issue.

Connection closed by foreign host. Shao-Seans-MacBook-Pro-5:~ shaosean$ telnet yahoo.com 80 Trying 206.190.36.45... Connected to yahoo.com. Escape character is '^]'. GET Yahoo html { height: 100%; } body { background: #fafafc url(https://s.yimg.com/nn/img/sad-panda-201402200631.png) 50% 50%; background-size: cover; height: 100%; text-align: center; font: 300 18px "helvetica neue", helvetica, verdana, tahoma, arial, sans-serif; } table { height: 100%; width: 100%; table-layout: fixed; border-collapse: collapse; border-spacing: 0; border: none; } h1 { font-size: 42px; font-weight: 400; color: #400090; } p { color: #1A1A1A; } #message-1 { font-weight: bold; margin: 0; } #message-2 { display: inline-block; *display: inline; zoom: 1; max-width: 17em; _width: 17em; }
Yahoo Logo

Will be right back...

Thank you for your patience.

Our engineers are working quickly to resolve the issue.

Connection closed by foreign host.[/code]