建立Reducisaurus网址

时间:2010-05-04 08:15:12

标签: php javascript web-services urlencode reducisaurus

我正在尝试使用Reducisaurus Web Service来缩小CSS和Javascript,但我遇到了一个问题......

假设我有两个未经通信化的CSS:

http:/domain.com/dynamic/styles/theme.php?color=red
http:/domain.com/dynamic/styles/typography.php?font=Arial

根据文档,我应该像这样调用Web服务:

http:/reducisaurus.appspot.com/css?url=http:/domain.com/dynamic/styles/theme.php?color=red

如果我想立刻缩小两个CSS文件:

http:/reducisaurus.appspot.com/css?url1=http:/domain.com/dynamic/styles/theme.php?color=red&url2=http:/domain.com/dynamic/styles/theme.php?color=red

如果我想为缓存指定不同的秒数(例如3600),我会使用:

http:/reducisaurus.appspot.com/css?url=http:/domain.com/dynamic/styles/theme.php?color=red&expire_urls=3600

同时对两个CSS文件一次:

http:/reducisaurus.appspot.com/css?url1=http:/domain.com/dynamic/styles/theme.php?color=red&url2=http:/domain.com/dynamic/styles/theme.php?color=red&expire_urls=3600

现在我的问题是,Reducisaurus如何知道如何分离我想要的URL?如何知道&expire_urls=3600不属于我的网址?那怎么知道&url2=...不是url1的GET参数?我这样做对吗?我需要urlencode我的网址吗?

我看了一下源代码,虽然我的Java非常差,但似乎methods acquireFromRemoteUrl() and getSortedParameterNames() from the BaseServlet.java file保留了我的问题的答案 - 如果GET参数名称包含-或{{1}他们应该被忽略?!

多个_怎么办?

2 个答案:

答案 0 :(得分:1)

是的,在将URL作为参数提交给其他Web服务之前,您需要对URL进行URL编码。

E.g。

http://google.com

变为

http%3A%2F%2Fgoogle.com

如果你这样做,那么像?,&,=等等特殊字符就不会在网络服务混淆的过程中存活下来。

(不太确定你提出的第二个问题是什么,抱歉。)

答案 1 :(得分:1)

以url开头的所有东西都被威胁为新的url,因此你不能将名为url2的参数作为url1的get参数传递。

每个不包含“ - ”的参数名称都将被视为输入。

所以,如果你这样做

...?file1=...&url1=...&max-age=604800,

max-age不会被视为输入。

然而,

...?file1=...&url1=...&maxage=604800

这里maxage将被视为输入。