Gallery/server strips port number from url for IE, but not Mozilla

march

Joined: 2002-08-15
Posts: 31
Posted: Mon, 2005-09-19 13:43

Hi...

I have G2 running on a webserver that has a port number in the url. Using mozilla, it seems to work just fine. But, using IE, I get a 'Network Error (tcp_error) A communication error occurred: "Operation timed out"' error, and the url that is displayed in the location bar is my site url without the port number, and main.php at the end.

In G1, I used to edit my config.php and add ":$SERVER_PORT" to my site url, but I don't see a way of doing this in G2.

Any help would be appreciated.

Thanks,

/greg

==================================================================

Get system details; useful for copy/paste into G2 support forum.

Last Run Details:

Gallery version = 2.0 core 1.0.0
PHP version = 4.4.0 apache
Webserver = Apache/1.3.27 (Unix) (Red-Hat/Linux) mod_ssl/2.8.12 OpenSSL/0.9.6b DAV/1.0.3 PHP/4.4.0 mod_perl/1.26
Database = mysqlt 3.23.58
Toolkits = ArchiveUpload, Exif, ImageMagick, NetPBM, Gd
Operating system = Linux bug.gfm.net 2.6.6 #4 SMP Sun Jun 6 14:15:05 EDT 2004 i686
Browser = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041217 MultiZilla/1.7.7.0e

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-09-19 15:24

for some reason, IE doesn't include the :443 in the host string in its SSL traffic with your website. Firefox does.
maybe a misconfired webserver, maybe that's the way IE works.
i don't have another SSL server to test if it's IE.

 
march

Joined: 2002-08-15
Posts: 31
Posted: Mon, 2005-09-19 15:28

It seems that there are other people having the same problem (see the main forum).

I'm pretty sure my apache is not configured in any way to affect this. And, in fact, it was working for G1 (see http://www.gfm.net:443/~march/gallery for an example).

Strange problem...

/greg

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-09-19 15:56

g1 and g2 generate urls in a different way. g2 requests a lot of information from the webserver to generate the correct protocol / host string.
why don't you access your g2 with https:// instead of http:// any reason?

 
march

Joined: 2002-08-15
Posts: 31
Posted: Mon, 2005-09-19 17:17
Quote:
why don't you access your g2 with https:// instead of http:// any reason?

It has to do with isp's blocking port 80... I was running on 8000, then that got blocked, then 8080... You get the idea. :-)

Regardless, I would think the port should be preserved, shouldn't it?

I was looking at the makeUrl method and changed it to insert the port, but it didn't seem to work. I'm willing to hack my code to get it to work so it doesn't have to be in the mainstream, but I just don't know / have the time to find where it is.

Thanks,

/greg

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-09-19 19:09

yep, modules/classes/GalleryUrlGenerator function makeUrl is the right place to hack.

when using https:// your browser should use port 443, so i don't see the problem there.

 
march

Joined: 2002-08-15
Posts: 31
Posted: Mon, 2005-09-19 19:34

Unfortunately, it doesn't. It's been a while since I looked into this, but I believe if you put "https" then you actually need to be sending the stream as an SSL stream, and you need certificates, etc.

I am using standard http over port 443 which is different. Just like 8080 or 8000, etc.

Thanks...

/greg

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-09-19 19:42

well, what do you propose? internet explorer doesn't request www.gfm.net:443 in its second packet, it requests host www.gfm.net.
firefox doesn't make that mistake.

 
march

Joined: 2002-08-15
Posts: 31
Posted: Mon, 2005-09-19 19:56

OK, here is what I did, and it works, but I haven't tested it with all possibilities.

HTH...

/greg
-------------------------------

    /**
     * Add given path to current protocol/server/port to create full url
     * @param string the url path; leading slash will be added if missing
     * @return string the url
     * @static
     */
    function makeUrl($path) {
        // Get the server's port
        $port = GalleryUtilities::getServerVar('SERVER_PORT');

        $protocol = (GalleryUtilities::getServerVar('HTTPS') == 'on') ? 'https' : 'http';
        $domain = GalleryUrlGenerator::getCurrentDomain();
        if (empty($path)) {
            $path = '/';  
        } else if ($path{0} != '/') {
            $path = '/' . $path;  
        }  

        // Pass the port in the url if it is non-standard (i.e. not 80 and not https on 443)
        if($port != "80" && !($port == "443" && $protocol == "https"))
            $mod_port = ":" . $port;

        return sprintf('%s://%s%s%s', $protocol, $domain, $mod_port, $path);
    }
 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-09-19 20:17

first, find out what you get for GalleryUtilities::getServerVar('SERVER_PORT'); on your server

e.g. add:
var_dump(GalleryUtilities::getServerVar('SERVER_PORT'));
exit;
and then access the page with IE and with FF.

        if($port != "80" && !($port == "443" && $protocol == "https"))
            $mod_port = ":" . $port;

        return sprintf('%s://%s%s%s', $protocol, $domain, $mod_port, $path);

isn't ok, since $mod_port isn't defined in all cases and you use it 2 lines below.
so it should rather be:

        if($port != "80" && !($port == "443" && $protocol == "https")) {
            $port = ":" . $port;
        }

        return sprintf('%s://%s%s%s', $protocol, $domain, $port, $path);

and now let's look at the logic:
i've just tested the code from g 2.0, not your modified code. and i've changed my webserver to listen on 8080 instead of 80. it works, also with [i]IE. all urls have :8080 in them.

so it's a misconfigured webserver or a problem with 443 in your case. try your luck with port 8080 or any non 443 port, since IE might to be "smart" by replacing 443 with https.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-09-19 20:18

confirmed, IE just tries to be "smart" with port 443. don't use port 443, if you try to be smart and trick your ISP :)

 
march

Joined: 2002-08-15
Posts: 31
Posted: Tue, 2005-09-20 11:13
valiant wrote:
first, find out what you get for GalleryUtilities::getServerVar('SERVER_PORT'); on your server

e.g. add:
var_dump(GalleryUtilities::getServerVar('SERVER_PORT'));
exit;
and then access the page with IE and with FF.

Both return 443.

Quote:
        if($port != "80" && !($port == "443" && $protocol == "https"))
            $mod_port = ":" . $port;

        return sprintf('%s://%s%s%s', $protocol, $domain, $mod_port, $path);

isn't ok, since $mod_port isn't defined in all cases and you use it 2 lines below.
so it should rather be:

        if($port != "80" && !($port == "443" && $protocol == "https")) {
            $port = ":" . $port;
        }

        return sprintf('%s://%s%s%s', $protocol, $domain, $port, $path);

Agreed. $mod_port is not defined (I knew that - but php handles that just fine). We also can't do it the way you suggest since $port would be just plain "80" for normal servers, and the url would be http://foo.com80/ with no ":". If the gallery team insists on not using undefined vars, then simply put a $mod_port = ""; before the if and we should be just fine.

Quote:
and now let's look at the logic:
i've just tested the code from g 2.0, not your modified code. and i've changed my webserver to listen on 8080 instead of 80. it works, also with [i]IE. all urls have :8080 in them.

so it's a misconfigured webserver or a problem with 443 in your case. try your luck with port 8080 or any non 443 port, since IE might to be "smart" by replacing 443 with https.

As you said in a later post, it does appear that IE is doing something funny. Unfortunately, I have no choice but to run http over port 443 in my situation. Additionally, I see no problems with introducing this logic as it is correct. However, if it is an issue, I would say that it is still prudent of the team to test the protocol if using port 443 and adjust the url appropriately.

I'd be curious as to what you think.

Cheers!

/greg

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-09-20 13:40

your $mod_port = ":" . $port; line only works because the condition in the if clause is always true. else you'd get an error.
my code if of course also wrong, since it doesn't do anything.

i suggest you do:

        // Pass the port in the url if it is non-standard (i.e. not 80 and not https on 443)
        $portString = '';
        if($port != "80" && !($port == "443" && $protocol == "https")) {
            $portString = ':' . $port;
        }

        return sprintf('%s://%s%s%s', $protocol, $domain, $portString, $path);

I agree with your logic, it seems to make sense. I'm not sure if there is a case where this makes anything worse.
Could you file a feature request to change makeUrl to the above code? Then not only me, but other G2 devs too will think about it.

Since the above code only fixes the case: HTTP (not HTTPS) + IE + port 443, it's a very uncommon case. Most users that have to use a non standard port can use 8080 or any other port and are not forced to use 443.

 
march

Joined: 2002-08-15
Posts: 31
Posted: Tue, 2005-09-20 14:03
valiant wrote:
Could you file a feature request to change makeUrl to the above code? Then not only me, but other G2 devs too will think about it.

Sure - do you mean over on SF or on one of these forums?

Thanks,

/greg

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-09-20 14:22
 
march

Joined: 2002-08-15
Posts: 31
Posted: Tue, 2008-08-19 11:52

Just curious... I'm about to upgrade gallery again. Every time I do, I have the problem that I originally reported in this thread. I had submitted a bug request, but it seems that when I search for it now on SF, I can't find it. However, I was able to dig it up from my old email, and here it is:

https://sourceforge.net/tracker/?func=detail&atid=357130&aid=1296430&group_id=7130

Was this ever addressed? (I guess if it was, the fix didn't work since I still have the problem).

I'd like to help out - I can post again what the fix I make for G2 is. Please let me know.

Thanks,

/greg