RC-Paves3-build / plovr

Automatically exported from code.google.com/p/plovr
0 stars 0 forks source link

getServerForExchange is unreliable to get address in server mode #69

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Set up plovr in serve mode with compilation RAW in a server
2. Visit the server page with a browser/proxy that strips referrer
3. all generated paths (deps.js , base.js , etc) are in localhost:9810

What is the expected output? What do you see instead?
The generated paths should be in SERVER_ADDRESS:9810

What version of the product are you using? On what operating system?
CentOS 5.5

plovr hg clone (latest)
or
plovr-4b3caf2b7d84.jar (latest release)

java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.8) (rhel-1.27.1.10.8.el5_8-i386)
OpenJDK Client VM (build 20.0-b11, mixed mode)

Please provide any additional information below.

As documented in http://plovr.com/javadoc/org/plovr/CompilationServer.html the 
function getServerForExchange is unreliable since it base the return value on 
the referrer. In some cases (eg. privacy proxy) that value is NULL.
Also I'm experiencing problems with a CentOS 5.5 server even if the referrer is 
not stripped from the GET request (maybe the openjdk version is buggy?) but not 
on my ubuntu machine nor my personal debian server.

Citing the documentation:
"If the hostname is not specified in the config file, and it cannot be 
determined from the referrer, then it is assumed to be localhost."

but there is no config option so I decided to patch the sources (see 
attachment) to include the option "server-domain" that can of course be 
inherited from the main config and accept a string containing the domain name 
eg:

{
        "mode": "RAW",
        "level": "VERBOSE",
        "output-wrapper": "(function(){%output%})();",
        "paths": "../",
        "server-domain": "tre.piccoli.porcellini.com"
}

If the config option is NULL (or not present) it uses the classic method 
otherwise it returns http://server-domain:port

Please let me know if I need to change something in the patch to get it 
accepted.

Original issue reported on code.google.com by fabio.al...@gmail.com on 5 Jul 2012 at 4:11

GoogleCodeExporter commented 8 years ago
Sorry, previous patch was missing getViewSourceUrlForExchange part, attached is 
the complete patch.

Original comment by fabio.al...@gmail.com on 9 Jul 2012 at 7:19

Attachments:

GoogleCodeExporter commented 8 years ago
I have the flip side of this problem: my origin HTML server is remote, e.g.

    http://foo.com/,

but it points to script tags that are local, e.g.

    http://localhost:9810/compile?id=foo&mode=RAW.

In this scenario, plovr returns Javascript with urls like:

    http://foo.com:9810/input/foo/...

This strikes me as quite a common use case. Why are we using referrer at all? 
Shouldn't we just be using the HTTP host header?

Original comment by hun...@twilio.com on 16 Aug 2012 at 9:26