/[storm]/storm/org/nongnu/storm/util/HTTPProxy.java
ViewVC logotype

Diff of /storm/org/nongnu/storm/util/HTTPProxy.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.26 by tuukkah, Thu May 8 15:29:32 2003 UTC revision 1.27 by tuukkah, Thu May 8 16:13:15 2003 UTC
# Line 85  public class HTTPProxy implements Runnab Line 85  public class HTTPProxy implements Runnab
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    
# Line 135  public class HTTPProxy implements Runnab Line 142  public class HTTPProxy implements Runnab
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);
# Line 201  public class HTTPProxy implements Runnab Line 207  public class HTTPProxy implements Runnab
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");

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.27

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26