/[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.24 by tuukkah, Thu May 8 14:10:43 2003 UTC revision 1.25 by tuukkah, Thu May 8 15:12:36 2003 UTC
# Line 105  public class HTTPProxy implements Runnab Line 105  public class HTTPProxy implements Runnab
105                      backlinks = true;                      backlinks = true;
106                  }                  }
107                                    
108                  if(uri.equals("") || uri.equals("rewrite")) {                  if(uri.equals(""))
109                      if(uri.equals("rewrite")) rewrite = true;                     return serveHomePage(rewrite, backlinks, resf);
110                        
                     HTTPResponse resp = resf.makeResponse(200, "Ok");  
                     resp.setField("Content-Type", "text/html");  
                     Writer w = new OutputStreamWriter(resp.getOutputStream(), "US-ASCII");  
                     w.write("<html><head><title>Storm gateway</title>" +  
                             "</head><body>\n");  
                     w.write("<h1>Storm gateway</h1>\n");  
   
                     writeRewriteLinks(w, rewrite);  
   
                     for(Iterator i=pool.getIds().block().iterator();  
                         i.hasNext();) {  
                         BlockId id = (BlockId)i.next();  
                         String s = id.getURI();  
                         if(rewrite) s = ROOTURL+REWRITE+"/" + s;  
                         w.write("<a href=\""+s+"\">"+id+"</a><br>\n");  
                     }  
                     w.write("</body></html>\n");  
                     w.close();  
                     return resp;  
                 }  
111    
112                  BlockId id = new BlockId(uri);                  BlockId id = new BlockId(uri);
113    
# Line 231  public class HTTPProxy implements Runnab Line 211  public class HTTPProxy implements Runnab
211                  w.write("<p>If your browser <em>is not</em> configured ");                  w.write("<p>If your browser <em>is not</em> configured ");
212                  w.write("to use this gateway as a proxy for URNs, ");                  w.write("to use this gateway as a proxy for URNs, ");
213                  w.write("you can use ");                  w.write("you can use ");
214                  w.write("<a href=\"rewrite/\">URI-rewriting version</a> ");                  w.write("<a href=\"/rewrite/\">URI-rewriting version</a> ");
215                  w.write("instead.</p>\n");                  w.write("instead.</p>\n");
216              } else {              } else {
217                  w.write("<p>If your browser <em>is</em> configured ");                  w.write("<p>If your browser <em>is</em> configured ");
218                  w.write("to use this gateway as a proxy for URNs, ");                  w.write("to use this gateway as a proxy for URNs, ");
219                  w.write("you can use ");                  w.write("you can use ");
220                  w.write("<a href=\"../\">Non-URI-rewriting version</a> ");                  w.write("<a href=\"/\">Non-URI-rewriting version</a> ");
221                  w.write("instead.</p>\n");                  w.write("instead.</p>\n");
222              }              }
223              w.write("<p>");              w.write("<p>");
# Line 247  public class HTTPProxy implements Runnab Line 227  public class HTTPProxy implements Runnab
227                      +ROOTURL+URNPAC+"</a></p>\n");                      +ROOTURL+URNPAC+"</a></p>\n");
228          }          }
229    
230            protected HTTPResponse serveHomePage(boolean rewrite,
231                                                 boolean backlinks,
232                                                 HTTPResponse.Factory resf)
233                throws IOException {
234    
235                String base = ROOTURL;
236                if(rewrite) base += REWRITE+"/";
237                if(backlinks) base += BACKLINKS+"/";
238    
239                HTTPResponse resp = resf.makeResponse(200, "Ok");
240                resp.setField("Content-Type", "text/html");
241                Writer w = new OutputStreamWriter(resp.getOutputStream(), "US-ASCII");
242                w.write("<html><head><title>Storm gateway</title>" +
243                        "</head><body>\n");
244                w.write("<h1>Storm gateway</h1>\n");
245                
246                writeRewriteLinks(w, rewrite);
247    
248                for(Iterator i=pool.getIds().block().iterator();
249                    i.hasNext();) {
250                    BlockId id = (BlockId)i.next();
251                    String s = id.getURI();
252                    if(rewrite) s = ROOTURL+REWRITE+"/" + s;
253                    w.write("<a href=\""+s+"\">"+id+"</a><br>\n");
254                }
255                w.write("</body></html>\n");
256                w.close();
257                return resp;
258            }
259            
260          protected HTTPResponse serveBlock(String uri,          protected HTTPResponse serveBlock(String uri,
261                                            HTTPResponse.Factory resf)                                            HTTPResponse.Factory resf)
262              throws Exception {              throws Exception {

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

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