[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java
From: |
Tuukka Hastrup |
Subject: |
[Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java |
Date: |
Sat, 26 Apr 2003 04:40:55 -0400 |
CVSROOT: /cvsroot/storm
Module name: storm
Changes by: Tuukka Hastrup <address@hidden> 03/04/26 04:40:55
Modified files:
org/nongnu/storm/util: HTTPProxy.java
Log message:
URN proxying for NS4
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/org/nongnu/storm/util/HTTPProxy.java.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
Patches:
Index: storm/org/nongnu/storm/util/HTTPProxy.java
diff -u storm/org/nongnu/storm/util/HTTPProxy.java:1.11
storm/org/nongnu/storm/util/HTTPProxy.java:1.12
--- storm/org/nongnu/storm/util/HTTPProxy.java:1.11 Fri Apr 25 12:55:28 2003
+++ storm/org/nongnu/storm/util/HTTPProxy.java Sat Apr 26 04:40:55 2003
@@ -44,17 +44,20 @@
protected StormPool pool;
protected int port;
+ protected String addr;
protected String url;
protected String REWRITE;
+ protected String URNPAC;
protected HTTPServer server;
public HTTPProxy(StormPool pool, int port) throws IOException {
this.pool = pool;
this.port = port;
- String addr = InetAddress.getLocalHost().getCanonicalHostName();
+ this.addr = InetAddress.getLocalHost().getCanonicalHostName();
this.url = "http://"+addr+":"+port+"/";
this.REWRITE = url+"rewrite/";
+ this.URNPAC = "urn-proxy.pac";
this.server = new HTTPServer(new Factory(), port);
}
@@ -83,6 +86,8 @@
if(uri.startsWith("rewrite/")) {
uri = uri.substring("rewrite/".length());
rewrite = true;
+ } else if(uri.equals(URNPAC)) {
+ return makePAC(req, resf);
}
if(uri.equals("") || uri.equals("rewrite")) {
@@ -94,10 +99,9 @@
w.write("<html><head><title>Storm gateway</title>" +
"</head><body>\n");
w.write("<h1>Storm gateway</h1>\n");
- if(!rewrite)
- w.write("<p><a href=\"rewrite/\">URI-rewriting
version</a></p>\n");
- else
- w.write("<p><a href=\"../\">Non-URI-rewriting
version</a></p>\n");
+
+ writeRewriteLinks(w, rewrite);
+
for(Iterator i=pool.getIds().block().iterator();
i.hasNext();) {
BlockId id = (BlockId)i.next();
@@ -146,6 +150,45 @@
e.printStackTrace();
return resf.makeError(500, "Internal error");
}
+ }
+
+ protected void writeRewriteLinks(Writer w, boolean rewrite)
+ throws IOException {
+ if(!rewrite) {
+ w.write("<p>If your browser <em>is not</em> configured ");
+ w.write("to use this gateway as a proxy for URNs, ");
+ w.write("you can use ");
+ w.write("<a href=\"rewrite/\">URI-rewriting version</a> ");
+ w.write("instead.</p>\n");
+ } else {
+ w.write("<p>If your browser <em>is</em> configured ");
+ w.write("to use this gateway as a proxy for URNs, ");
+ w.write("you can use ");
+ w.write("<a href=\"../\">Non-URI-rewriting version</a> ");
+ w.write("instead.</p>\n");
+ }
+ w.write("<p>");
+ w.write("To configure URN proxy in Netscape Navigator 4, ");
+ w.write("Automatic Proxy Configuration location can be set to ");
+ w.write("<a href=\""+url+URNPAC+"\">"+url+URNPAC+"</a></p>\n");
+ }
+
+ protected HTTPResponse makePAC(HTTPRequest req,
+ HTTPResponse.Factory resf)
+ throws IOException {
+ HTTPResponse resp = resf.makeResponse(200, "Ok");
+ resp.setField("Content-Type",
+ "application/x-ns-proxy-autoconfig");
+ Writer w = new OutputStreamWriter(resp.getOutputStream(),
+ "US-ASCII");
+ w.write("function FindProxyForURL(url,host) {\n");
+ w.write("if (url.substring(0, 4) == \"urn:\") {\n");
+ w.write("return \"PROXY "+addr+":"+port+"\";\n");
+ w.write("} else {\n");
+ w.write("return \"DIRECT\";\n");
+ w.write("}}\n");
+ w.close();
+ return resp;
}
}
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Benja Fallenstein, 2003/04/23
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Tuukka Hastrup, 2003/04/24
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Tuukka Hastrup, 2003/04/24
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Tuukka Hastrup, 2003/04/25
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Tuukka Hastrup, 2003/04/25
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Tuukka Hastrup, 2003/04/25
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Tuukka Hastrup, 2003/04/25
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Tuukka Hastrup, 2003/04/25
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java,
Tuukka Hastrup <=