IsCrossDomainEnabled设置:
mServer.IsCrossDomainEnabled = true;
CrossDomainXmlContent设置:
//mServer.CrossDomainXmlContent =
// "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n<!DOCTYPE cross-domain-policy SYSTEM\n\n\t\"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\" >\n\n<cross-domain-policy>\n\n\t<site-control permitted-cross-domain-policies=\"all\" />\n\n\t<allow-access-from domain=\"*\" />\n\n\t<allow-http-request-headers-from domain=\"*\" headers=\"*\"/>\n\n</cross-domain-policy>";
curl命令:
curl -d "Cs14\"sendSimpleText\"a1{s5\"world\"}z" http://192.168.1.105:4321/
Nepenthes:
http://www.hprose.com/test/
监听 | Is Cross Domain Enabled | Cross Domain Xml Content | curl | Nepenthes |
---|---|---|---|---|
http://192.168.1.105:4321 | false | 未设置 | fail | fail |
http://192.168.1.105:4321/ | false | 未设置 | ok | fail |
http://192.168.1.105:4321/ | true | 未设置 | ok | ok |
http://192.168.1.105:4321/ | true | 设置 | ok | ok |
http://0.0.0.0:4321/ | true | 设置 | ok | ok |
http://0.0.0.0:4321/ | true | 未设置 | ok | ok |
http://127.0.0.1:4321/ | true | 设置 | Bad Request (Invalid host) | Bad Request (Invalid host) |
http://localhost:4321/ | true | 设置 | Bad Request (Invalid host) | Bad Request (Invalid host) |
如果本地clone Nepenthes,非跨域,也可正常访问。
结论:
1. 端口后没有加/不能正常监听!
2. 如果设置http://127.0.0.1:port/或http://localhost:port/ 只能本地访问。
3. 如果局域网访问,设置http://0.0.0.0:port/ 可避免需要绑定具体的端口。
4. 如果希望跨域访问,还需要设置IsCrossDomainEnabled。
5. 如果希望支持flash的跨域访问,还需要设置CrossDomainXmlContent。