?

Log in

Does anyone here have write access to a PHP web server? - Ron Newman [entries|archive|friends|userinfo]
Ron Newman

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Does anyone here have write access to a PHP web server? [Mar. 11th, 2011|08:57 pm]
Ron Newman
I am investigating an unfortunate interaction between a Facebook feature (the "always use https" preference) and the behavior of certain browsers (definitely Mac Safari, perhaps others) when they receive an HTTP "302" redirect.

To do this, I'd like to put a PHP file and a couple of HTML pages up on a web server, and then have a few people bang on the PHP page from various browsers on various operating systems. I'm especially interested in how Internet Explorer behaves, but I can't test this locally at home because I have only a Mac.

Can anyone help?

Specifically, I'm investigating the behavior of browsers when Facebook redirects a URL of the following format from http to https:

http://www.facebook.com/#!/YoungSomerville

On my Mac, Safari 5.0.3 responds to the redirect by going to https://www.facebook.com/ , while Firefox 3.6.15, Camino 2.0.6, Chrome 10.0.648.133, and Opera 11.01 all go to
https://www.facebook.com/#!/YoungSomerville .

The latter behavior seems much more useful, and presumably is what Facebook expects, but it's not clear to me whether any official standards require it. I'd like to know how Internet Explorer and other PC browsers (and Linux browsers, for that matter) behave.

So if you can take a few small files from me and put them on a public web server that can run PHP, I'd greatly appreciate it.
linkReply

Comments:
[User Picture]From: nosrednayduj
2011-03-12 02:47 am (UTC)
We're running some sort of web server on olum.org. "ps" reveals some apache processes with happy looking arguments like "-DHAVE_PHP5". But I don't have any idea how to test if it works. You could email me a tar or zip file with some contents and I could put it up as http://www.olum.org/yduj/ron and you could do whatever you wanted. Well, within reason ;-)
(Reply) (Thread)
[User Picture]From: ron_newman
2011-03-12 03:08 am (UTC)
Thanks. I just sent a tar file to the e-mail address listed in your LJ profile.
(Reply) (Parent) (Thread)
[User Picture]From: nosrednayduj
2011-03-12 03:27 am (UTC)
For others interested in helping, it's now up at http://www.olum.org/yduj/redir_frag. Have fun, and report your browser version and the results you got from the four tests. I did IE 8 and FF 3.6 on a PC and a really old FF 3.0 on linux. And lynx, just for grins.
(Reply) (Thread)
[User Picture]From: ron_newman
2011-03-12 03:36 am (UTC)
Thanks! The results I get on my Mac:

No old or new fragment: "" in all my browsers

Old fragment only: "" in Safari 5.04; "#old" in Firefox 3.6.15, Camino 2.0.6, Chrome 10.0.648.133, and Opera 11.01. I consider Safari's behavior to be broken.

New fragment only: "#new" in all my browsers

Both old and new fragments: "#old" in Opera, "#new" in Safari, Firefox, Camino, and Chrome. I wonder why Opera is choosing different behavior from the others.

(What results did you get from your tests, Judy?)

Edited at 2011-03-12 04:02 am (UTC)
(Reply) (Parent) (Thread)
[User Picture]From: nosrednayduj
2011-03-12 02:02 pm (UTC)
IE: "" "" "#new" "#new"
FF (both): "" "#old" "#new" "#new"
(Reply) (Parent) (Thread)
[User Picture]From: ron_newman
2011-03-12 07:10 pm (UTC)
Thanks. So IE also behaves (in my opinion) wrongly, and Safari may have just copied that behavior.

I don't know whether it is possible to run more than one version of IE on a PC. If you have other versions of IE around (9, 7, 6), can you try them as well?
(Reply) (Parent) (Thread)
[User Picture]From: nosrednayduj
2011-03-12 08:38 pm (UTC)
There's an ancient win2k machine at work with IE 6, and a somewhat oldish un-updated machine with IE7. Identical behavior ("", "", "#new", "#new") in both. Interestingly, in IE6, when I went "back" after doing the first one, the "old only" link was purple as well as the "no frag" link! But when I hovered, tooltips showed the text of the link different (with and without the #old). IE7 only purpled the links after I'd actually clicked on them individually. Can't remember what happened with IE8. Don't have IE9. Hoping to avoid it. Wasn't thrilled with the forced switch to IE8.
(Reply) (Parent) (Thread)
[User Picture]From: ron_newman
2011-03-12 08:45 pm (UTC)
Thank you so much, Judy. If you can leave my files up for a few more days, maybe I can find someone else to try it with IE9.

This appears to be a Python script running a self-contained little web server (no Apache needed) to test the same thing: https://gist.github.com/330963

Edited at 2011-03-12 08:46 pm (UTC)
(Reply) (Parent) (Thread)
[User Picture]From: nosrednayduj
2011-03-12 08:55 pm (UTC)
Yeah, sure, it's not like it's taking a lot of resources.

I don't get what I would do with the github test; put it directly in my html directory (where "/yduj" goes) as redir_frag.py? Or is there some html that needs to wrap it too? As you may have guessed, I'm kind of clue free about anything that isn't just writing <html>blah</html>. (OK, so I proved I know about ampersand lt there. But that's about the limit of my trickiness.)
(Reply) (Parent) (Thread)
[User Picture]From: ron_newman
2011-03-12 08:59 pm (UTC)
Don't worry about the Python unless you feel like it. You run it from the command line:

./redir_frag_test.py localhost port_number

and it runs its own little self-contained web server on that port. It requires that Python library, nbhttp , be installed, which is at http://github.com/mnot/nbhttp .
(Reply) (Parent) (Thread)
[User Picture]From: nosrednayduj
2011-03-12 09:03 pm (UTC)
OK. I'll pass on that, someone else can help you with that test...
(Reply) (Parent) (Thread)
[User Picture]From: ron_newman
2011-03-12 08:56 pm (UTC)
While Lynx has no knowledge of JavaScript and therefore can't display the fragment ID on the web page, its redirection behavior appears to be identical to Firefox and Chrome.
(Reply) (Parent) (Thread)
[User Picture]From: ron_newman
2011-03-12 03:40 am (UTC)
An explanation of what this is testing:

Clicking on any of the four links invokes a PHP script that uses a 302 redirect to another page. The difference between the four involves the processing of the fragment identifier -- the string after "#" in a URL.

"No old or new fragment" uses a link without an 'old' fragment identifier, and tells the PHP script not to add its own 'new' fragment identifier to the URL it redirects to.

"Old fragment only" uses a link with an 'old' fragment identifier, and tells the PHP script not to add its own 'new' fragment identifier.

"New fragment only" uses a link without an 'old' fragment identifier, but tells the PHP script to add its own 'new' fragment identifier when redirecting.

"Both old and new fragments" uses a link with an 'old' fragment identifier, but also tells the PHP script to add its own 'new' fragment identifier when redirecting.

You can see the two HTML files (index.html and foo.html) by using 'View Source' in your browser. Here's the PHP script that is invoked by each of the links:

<?php
// Redirect to a specified local page, relative to the current page.
// This is adapted from a 'Note' at  http://www.php.net/manual/en/function.header.php  
function redirect($page) {
    $url = 'http://' . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['PHP_SELF']), '/') . "/$page";
    header("Location: $url");
    exit();   	// don't do anything else after redirecting!
}

$newfrag = $_GET['newfrag'];
$newfrag = isset($newfrag) ? "#$newfrag" : "";
redirect("foo.html$newfrag")
?>


Edited at 2011-03-12 03:48 am (UTC)
(Reply) (Thread)
[User Picture]From: nu_luba
2011-03-12 11:44 am (UTC)
i get ""
#old
#new
#new

in firefox

""
""
#new
#new

in safari

""
#old
#new
#new

in flock
(Reply) (Parent) (Thread)
[User Picture]From: ron_newman
2011-03-12 11:52 am (UTC)
Thanks What version of these browsers, and on what operating system?
(Reply) (Parent) (Thread)
[User Picture]From: nu_luba
2011-03-12 11:59 am (UTC)
mac os 10.6.6

firefox 3.6.15

safari 5.0.3

flock 1.2.7
(Reply) (Parent) (Thread)
[User Picture]From: ron_newman
2011-03-12 12:02 pm (UTC)
Thanks, especially for testing Flock (a browser I'm unfamiliar with).
(Reply) (Parent) (Thread)
[User Picture]From: nu_luba
2011-03-12 12:06 pm (UTC)
not a problem. Incidentally, i just upgrade to firefox 4 beta and am seeing the same behavior as firfox 3.6.15
(Reply) (Parent) (Thread)
[User Picture]From: ron_newman
2011-03-12 12:10 pm (UTC)
If at any point you get a chance to test with Internet Explorer, let me know.
(Reply) (Parent) (Thread)
[User Picture]From: nu_luba
2011-03-12 12:19 pm (UTC)
it will have to be monday. I refuse to have windows computers at home because it reminds me too much of work :)
(Reply) (Parent) (Thread)
[User Picture]From: ron_newman
2011-03-12 12:25 pm (UTC)
Thanks again. My personal belief is that Firefox, Flock, and Chrome are behaving 'correctly', while Safari and Opera are both deviating in different ways from proper behavior. But in the absence of a formal standard, it's hard for me to say this definitively.
(Reply) (Parent) (Thread)
[User Picture]From: nu_luba
2011-03-14 05:12 pm (UTC)

In IE 8

No old or new fragment: ""
Old Fragment Only: ""
New fragment only: "#new"
old and new fragment: "#new"
(Reply) (Parent) (Thread)
[User Picture]From: ron_newman
2011-03-14 05:14 pm (UTC)

Re: In IE 8

Thanks. Someone else tried IE9 and got the same results with that.
(Reply) (Parent) (Thread)
[User Picture]From: dsmoen
2011-03-12 11:48 am (UTC)
I'd definitely love to help you with this.

Further, I can help make sure any issues are fixed.

I'll PM you my work address.
(Reply) (Thread)
[User Picture]From: ron_newman
2011-03-12 11:53 am (UTC)
That would be great (but I don't see any PM from you yet). Some of these pages explain the problem further. Note that the IETF draft is from 1999!
(Reply) (Parent) (Thread)
[User Picture]From: dsmoen
2011-03-12 11:55 am (UTC)
I went to your info page and saw an email address, so I sent an email instead.
(Reply) (Parent) (Thread)
[User Picture]From: ron_newman
2011-03-12 12:01 pm (UTC)
Got it. I'll respond shortly.
(Reply) (Parent) (Thread)