Author: toad
Date: 2008-11-27 01:07:53 +0000 (Thu, 27 Nov 2008)
New Revision: 23896

Modified:
   trunk/freenet/src/freenet/clients/http/HTTPRequestImpl.java
   trunk/freenet/src/freenet/clients/http/RedirectException.java
   trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
   trunk/freenet/src/freenet/support/io/TempBucketFactory.java
Log:
Fix the can't-dismiss-useralerts bug (broke a number of web interface features 
which generally relied on POSTing to / and expecting it to be transparently 
redirected to /welcome/).
DETAILS: RedirectException keeps the old method and the old data, just uses a 
new URI.
Document this.
Don't free the data until we are out of the loop.


Modified: trunk/freenet/src/freenet/clients/http/HTTPRequestImpl.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/HTTPRequestImpl.java 2008-11-26 
22:37:17 UTC (rev 23895)
+++ trunk/freenet/src/freenet/clients/http/HTTPRequestImpl.java 2008-11-27 
01:07:53 UTC (rev 23896)
@@ -605,8 +605,7 @@
                }
                parts.clear();
                
-               if(data != null)
-                       data.free();
+               // Do not free data. Caller is responsible for that.
        }
 
        /* (non-Javadoc)

Modified: trunk/freenet/src/freenet/clients/http/RedirectException.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/RedirectException.java       
2008-11-26 22:37:17 UTC (rev 23895)
+++ trunk/freenet/src/freenet/clients/http/RedirectException.java       
2008-11-27 01:07:53 UTC (rev 23896)
@@ -6,6 +6,13 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 
+/**
+ * If thrown, the ToadletContainer re-runs the request with the new URI.
+ * Note that it DOES NOT change the method to "GET"! So you can redirect to 
another toadlet
+ * and expect the other toadlet to deal with a POST. However if you want to 
dump the contents
+ * of the POST, you need to actually write a redirect.
+ * @author Matthew Toseland <[EMAIL PROTECTED]> (0xE43DA450)
+ */
 public class RedirectException extends Exception {
        private static final long serialVersionUID = -1;
        URI newuri;

Modified: trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java      
2008-11-26 22:37:17 UTC (rev 23895)
+++ trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java      
2008-11-27 01:07:53 UTC (rev 23896)
@@ -341,6 +341,7 @@
                                }
                                
                                // Handle it.
+                               try {
                                boolean redirect = true;
                                while (redirect) {
                                        // don't go around the loop unless set 
explicitly
@@ -381,6 +382,9 @@
                                        sock.close();
                                        return;
                                }
+                               } finally {
+                                       if(data != null) data.free();
+                               }
                        }
                        
                } catch (ParseException e) {

Modified: trunk/freenet/src/freenet/support/io/TempBucketFactory.java
===================================================================
--- trunk/freenet/src/freenet/support/io/TempBucketFactory.java 2008-11-26 
22:37:17 UTC (rev 23895)
+++ trunk/freenet/src/freenet/support/io/TempBucketFactory.java 2008-11-27 
01:07:53 UTC (rev 23896)
@@ -152,7 +152,7 @@
                        hasWritten = true;
                        OutputStream os = new TempBucketOutputStream(++osIndex);
                        if(logMINOR)
-                               Logger.minor(this, "Got "+os+" for "+this);
+                               Logger.minor(this, "Got "+os+" for "+this, new 
Exception());
                        return os;
                }
 
@@ -238,7 +238,7 @@
                        TempBucketInputStream is = new 
TempBucketInputStream(osIndex);
                        tbis.add(is);
                        if(logMINOR)
-                               Logger.minor(this, "Got "+is+" for "+this);
+                               Logger.minor(this, "Got "+is+" for "+this, new 
Exception());
                        return is;
                }
                

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to