85 |
String uri = req.getRequestURI(); |
String uri = req.getRequestURI(); |
86 |
if(HTTPProxy.dbg) p("<"+port+"> GET: "+uri + " (" + this.getRemoteIPAddress() + ")"); |
if(HTTPProxy.dbg) p("<"+port+"> GET: "+uri + " (" + this.getRemoteIPAddress() + ")"); |
87 |
|
|
88 |
/* URN proxy requests start directly with "urn:" */ |
/* URN proxy requests don't start with slash */ |
89 |
if(!uri.startsWith("/")) |
if(!uri.startsWith("/")) |
90 |
return serveBlock(uri, resf); |
return serveBlock(uri, resf); |
91 |
else |
else |
92 |
uri = uri.substring(1); |
uri = uri.substring(1); |
93 |
|
|
94 |
if(uri.equals(URNPAC)) { |
if(uri.equals(URNPAC)) |
95 |
return makePAC(req, resf); |
return makePAC(req, resf); |
|
} |
|
96 |
|
|
97 |
if(uri.startsWith("rewrite/")) { |
String element; |
98 |
uri = uri.substring("rewrite/".length()); |
while(!uri.startsWith("urn:")) { |
99 |
rewrite = true; |
int slash = uri.indexOf('/'); |
100 |
|
if(slash != -1) { |
101 |
|
element = uri.substring(0, slash); |
102 |
|
uri = uri.substring(slash+1); |
103 |
|
} else { |
104 |
|
element = uri; |
105 |
|
uri = ""; |
106 |
|
} |
107 |
|
if(element.equals(REWRITE)) |
108 |
|
rewrite = true; |
109 |
|
else if(element.equals(BACKLINKS)) |
110 |
|
backlinks = true; |
111 |
|
else if(element.equals("")) |
112 |
|
return serveHomePage(rewrite, backlinks, resf); |
113 |
|
else |
114 |
|
throw new FileNotFoundException("Unknown: "+uri); |
115 |
} |
} |
116 |
|
|
117 |
if(uri.startsWith("backlinks/")) { |
/* At this point, only the block URN is left of URL */ |
|
uri = uri.substring("backlinks/".length()); |
|
|
backlinks = true; |
|
|
} |
|
|
|
|
|
if(uri.equals("")) |
|
|
return serveHomePage(rewrite, backlinks, resf); |
|
|
|
|
118 |
|
|
119 |
BlockId id = new BlockId(uri); |
BlockId id = new BlockId(uri); |
120 |
|
|
142 |
/* XXX If no rewrite, should the links be URNs or backlinks/ */ |
/* XXX If no rewrite, should the links be URNs or backlinks/ */ |
143 |
if(backlinks) |
if(backlinks) |
144 |
s = insertBacklinks(s, prefix, id); |
s = insertBacklinks(s, prefix, id); |
|
|
|
145 |
|
|
146 |
byte[] bytes = s.getBytes("US-ASCII"); |
byte[] bytes = s.getBytes("US-ASCII"); |
147 |
resp.getOutputStream().write(bytes); |
resp.getOutputStream().write(bytes); |
207 |
i.hasNext();) { |
i.hasNext();) { |
208 |
BlockId id = (BlockId)i.next(); |
BlockId id = (BlockId)i.next(); |
209 |
String s = id.getURI(); |
String s = id.getURI(); |
210 |
if(rewrite) s = ROOTURL+REWRITE+"/" + s; |
if(rewrite) s = base + s; |
211 |
w.write("<a href=\""+s+"\">"+id+"</a><br>\n"); |
w.write("<a href=\""+s+"\">"+id+"</a><br>\n"); |
212 |
} |
} |
213 |
w.write("</body></html>\n"); |
w.write("</body></html>\n"); |