Loading...
Pages: [1]   Go Down
Author Topic: Location Header in Served Web Page  (Read 219 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 47
Bald-Headed, Middle-Aged Nerd
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just for fun, I've been experimenting with URL redirection using the "Location" header sent before html.

Below is my Arduino code that makes the web page I am serving at http://thatsgoodbob.dyndns.org:8248/

The page redirects, as expected, to http://google.com when viewed in Firefox or Chrome.

BUT ... if I try to view the page in IE 8 or IE 9, no redirection happens, and the page in the code below appears.


I know this is not really an Arduino issue, but all of the answers I've found on the web have to do with PHP, which is not the issue here.

Does anything see anything in my code that explains what is happening ?

Thank you for helping me.

Bob W   (code follows . . )

Code:
   
  client.println("HTTP/1.1 301 Moved Permanently");
  client.println("Location: http://google.com");
  client.println("Content-Type: text/html; charset=iso-8859-1");
  client.println("Connection: close");
  client.println();

  client.println("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">");
  client.println("<html>");
  client.println("<body>");
  client.println("<h2>You should not be seeing this page . . .");
  client.println("</h2>"); 
  client.println("<br>"); 
  client.println("Because \"Location: http://google.com\" is in the header before the html.<br><br>");
  client.println("It redirects as expected in FF and Chrome.<br><br>");
  client.println("But this page displays in IE 8, 9<br><br>");
  client.println("What am I doing wrong ? <br><br>");

  client.println("</body>");
  client.println("</html>");
  client.stop();     
 
Logged

Global Moderator
Melbourne, Australia
Offline Offline
Shannon Member
*****
Karma: 218
Posts: 13896
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Read this:

http://en.wikipedia.org/wiki/HTTP_location

Try a trailing slash.
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 47
Bald-Headed, Middle-Aged Nerd
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Adding trailing slash to http://google.com did not change behavior.
Still works in FF, Chrome.
Not in IE 8, 9.
Thanks anyway though !

Bob W
Logged

NYC, US
Offline Offline
Sr. Member
****
Karma: 9
Posts: 412
I have no clue about Arduino, is it Italian coffee?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Could you try response 302? 

HTTP/1.1 302 Found
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 47
Bald-Headed, Middle-Aged Nerd
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Changed to  HTTP/1.1 302 Found

No change in behavior.
Logged

NYC, US
Offline Offline
Sr. Member
****
Karma: 9
Posts: 412
I have no clue about Arduino, is it Italian coffee?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Now you need tcp/ip sniffer to help.  if true it is bug and submit bug report to microsoft or shield OEM.
« Last Edit: February 10, 2013, 08:07:02 pm by sonnyyu » Logged

Global Moderator
Melbourne, Australia
Offline Offline
Shannon Member
*****
Karma: 218
Posts: 13896
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I reported a bug to Microsoft once. Thirty years ago, I think. I'm still waiting for a response.
Logged


0
Offline Offline
Tesla Member
***
Karma: 50
Posts: 6546
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe the IE people don't want their users being redirected to undesirable/unintended sites.
Logged

Why I like my 2005 rio yellow Honda S2000 with the top down, and more!
GOOGLE ADVANCED FORUM SEARCH BELOW!  
Go to:  http://www.google.com/advanced_search?hl=en
put in key search words,
use site or domain:  http://arduino.cc/forum
or in a google search box put key words site:http://arduino.cc/forum

NYC, US
Offline Offline
Sr. Member
****
Karma: 9
Posts: 412
I have no clue about Arduino, is it Italian coffee?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.httpwatch.com/

HttpWatch is an integrated HTTP sniffer for IE and Firefox
that provides new insights into how your website loads and performs.

HttpWatch Basic Version is free.

If you have chance please test it with IE 7, 6,5,4...
one time I my ghost back old windows 2000 image, and its IE 4 or 5 crashed at almost any modern web site. But it might be worked this one smiley
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 47
Bald-Headed, Middle-Aged Nerd
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK.
I beat it into submission.
The following code redirects properly in IE, FF and Chrome.
Problem seems to have been a missing <head> tag.
See http://thatsgoodbob.dyndns.org:8248 for demo.
Will be available for a short time longer.

Code follows.
Thanks for helping me !

Bob W.

Code:
  client.print("HTTP/1.1 301 Moved Permanently\r\n");
  client.print("Date: Mon, 11 Feb 2013 15:19:46 GMT\r\n");
  client.print("Server: Apache\r\n");
  client.print("Location: http://google.com/\r\n");
  client.print("Content-Length: 523\r\n");
  client.print("Connection: close\r\n");
  client.print("Content-Type: text/html; charset=iso-8859-1\r\n");
  client.print("\r\n");


  client.print("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n");
  client.print("<html><head>\n");
  client.print("<title>Test Page</title>\n");
  client.print("</head><body>\n");
  client.print("<h2>You should not be seeing this page . . .</h2>\n"); 
  client.print("<br>"); 
  client.print("Because \"Location: http://google.com\" is in the header before the html.<br><br>");
  client.print("It redirects as expected in FF and Chrome.<br><br>");
  client.print("But this page displays in IE 8, 9<br><br>");
  client.print("What am I doing wrong ? <br><br>");
  client.print("(v0.08 Monday)<br><br>");

  client.print("</body>");
  client.print("</html>\n");
  client.stop();     
}


Logged

Pages: [1]   Go Up
Print
 
Jump to: