/[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.44 by tuukkah, Mon May 26 18:54:17 2003 UTC revision 1.45 by benja, Tue May 27 02:22:50 2003 UTC
# Line 302  public class HTTPProxy implements Runnab Line 302  public class HTTPProxy implements Runnab
302          }          }
303    
304          protected String rewriteURIs(String s, String prefix) {          protected String rewriteURIs(String s, String prefix) {
305              String l = s.toLowerCase(); // XXX Why this?              // Block urns can be in upper or lower or mixed case;
306                // matching on the lower-case version makes
307                // our life much easier.
308                String l = s.toLowerCase();
309              int i = -1;              int i = -1;
310              while((i=l.indexOf("urn:x-storm:1.0:", i)) >= 0) {              while((i=l.indexOf("urn:x-storm:", i)) >= 0) {
311                  s = s.substring(0, i) + prefix + s.substring(i);                  s = s.substring(0, i) + prefix + s.substring(i);
312                  l = s.toLowerCase(); // XXX and this?                  l = s.toLowerCase();
313                  i += prefix.length() + 1;                  i += prefix.length() + 1;
314              }              }
315              return s;              return s;
316          }          }
317    
318            /** The reverse of rewriteURIs(s, prefix).
319             */
320            protected String unrewriteURIs(String s, String prefix) {
321                // Block urns can be in upper or lower or mixed case;
322                // matching on the lower-case version makes
323                // our life much easier.
324                String l = s.toLowerCase();
325                int i = -1;
326                while((i=l.indexOf(prefix+"urn:x-storm:", i)) >= 0) {
327                    s = s.substring(0, i) + s.substring(i+prefix.length());
328                    l = s.toLowerCase();
329                    i++;
330                }
331                return s;
332            }
333    
334          protected String insertBacklinks(String s, String prefix, BlockId id)          protected String insertBacklinks(String s, String prefix, BlockId id)
335              throws IOException {              throws IOException {
336              if(HTTPProxy.dbg) p("Getting HtmlLinkIndex.");              if(HTTPProxy.dbg) p("Getting HtmlLinkIndex.");
# Line 425  public class HTTPProxy implements Runnab Line 444  public class HTTPProxy implements Runnab
444              if(uri.startsWith("/"))              if(uri.startsWith("/"))
445                  uri = uri.substring(1);                  uri = uri.substring(1);
446    
447                boolean rewrite = false;
448                if(uri.startsWith(REWRITE+"/")) {
449                    uri = uri.substring(REWRITE.length()+1);
450                    rewrite = true;
451                }
452    
453              if(dbg) p("PUT accepted");              if(dbg) p("PUT accepted");
454              PointerId id = new PointerId(uri);              PointerId id = new PointerId(uri);
455              PointerIndex idx =              PointerIndex idx =
# Line 445  public class HTTPProxy implements Runnab Line 470  public class HTTPProxy implements Runnab
470              BlockOutputStream bos =              BlockOutputStream bos =
471                  pool.getBlockOutputStream(current.getContentType());                  pool.getBlockOutputStream(current.getContentType());
472    
473              CopyUtil.copy(req.getInputStream(), bos);              if(!rewrite || !current.getContentType().equals("text/html")) {
474                    CopyUtil.copy(req.getInputStream(), bos);
475                } else {
476                    String s = CopyUtil.readString(req.getInputStream());
477                    String prefix = ROOTURL+REWRITE+"/";
478                    s = unrewriteURIs(s, prefix);
479                    bos.write(s.getBytes("US-ASCII"));
480                }
481    
482              if(dbg) p("Created new block: "+bos.getBlockId());              if(dbg) p("Created new block: "+bos.getBlockId());
483    
# Line 536  public class HTTPProxy implements Runnab Line 568  public class HTTPProxy implements Runnab
568              if(dbg) p("Return response");              if(dbg) p("Return response");
569              return resp;              return resp;
570          }                }      
571    
572            protected HTTPResponse doPropfind(HTTPRequest req, HTTPResponse.Factory resf)
573                throws IOException {
574                // XXX absolutely dummy implementation
575            }
576      }          }    
577    
578      protected BlockId getBlockId(String uri) {      protected BlockId getBlockId(String uri) {

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.45

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