Author: toad
Date: 2006-12-15 22:07:25 +0000 (Fri, 15 Dec 2006)
New Revision: 11427

Modified:
   trunk/freenet/src/freenet/clients/http/BrowserTestToadlet.java
   trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
   trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
   trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
   trunk/freenet/src/freenet/clients/http/LocalFileInsertToadlet.java
   trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java
   trunk/freenet/src/freenet/clients/http/PluginToadlet.java
   trunk/freenet/src/freenet/clients/http/PproxyToadlet.java
   trunk/freenet/src/freenet/clients/http/QueueToadlet.java
   trunk/freenet/src/freenet/clients/http/StaticToadlet.java
   trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
   trunk/freenet/src/freenet/clients/http/SymlinkerToadlet.java
   trunk/freenet/src/freenet/clients/http/Toadlet.java
   trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
Log:
Include HTTPRequest in Toadlet API.

Modified: trunk/freenet/src/freenet/clients/http/BrowserTestToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/BrowserTestToadlet.java      
2006-12-15 21:59:26 UTC (rev 11426)
+++ trunk/freenet/src/freenet/clients/http/BrowserTestToadlet.java      
2006-12-15 22:07:25 UTC (rev 11427)
@@ -174,10 +174,7 @@
                "TTfltFP4CgA1VFFFraqAAAIANUIAYJzwRFRHhRVWT2eltVZbb8U1V1135bVX" +
                "X38FNlhhhyW2WGOPRTZZZbEMCAA7====";

-       public void handleGet(URI uri, ToadletContext ctx) throws 
ToadletContextClosedException, IOException {
-               final boolean advancedEnabled = core.isAdvancedDarknetEnabled();
-               HTTPRequest request = new HTTPRequestImpl(uri);
-               
+       public void handleGet(URI uri, HTTPRequest request, ToadletContext ctx) 
throws ToadletContextClosedException, IOException {
                // Yes, we need that in order to test the browser (number of 
connections per server)
                if (request.isParameterSet("wontload")) return;
                else if (request.isParameterSet("mimeTest")){

Modified: trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ConfigToadlet.java   2006-12-15 
21:59:26 UTC (rev 11426)
+++ trunk/freenet/src/freenet/clients/http/ConfigToadlet.java   2006-12-15 
22:07:25 UTC (rev 11427)
@@ -35,12 +35,10 @@
                this.node = node;
        }

-       public void handlePost(URI uri, Bucket data, ToadletContext ctx) throws 
ToadletContextClosedException, IOException {
+       public void handlePost(URI uri, HTTPRequest request, ToadletContext 
ctx) throws ToadletContextClosedException, IOException {
                StringBuffer errbuf = new StringBuffer();
                SubConfig[] sc = config.getConfigs();

-               HTTPRequest request = new HTTPRequestImpl(uri, data, ctx);
-               
                String pass = request.getPartAsString("formPassword", 32);
                if((pass == null) || !pass.equals(core.formPassword)) {
                        MultiValueTable headers = new MultiValueTable();
@@ -101,7 +99,7 @@

        }

-       public void handleGet(URI uri, ToadletContext ctx) throws 
ToadletContextClosedException, IOException {
+       public void handleGet(URI uri, HTTPRequest req, ToadletContext ctx) 
throws ToadletContextClosedException, IOException {
                SubConfig[] sc = config.getConfigs();
                Arrays.sort(sc);
                boolean advancedEnabled = core.isAdvancedDarknetEnabled();

Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java       
2006-12-15 21:59:26 UTC (rev 11426)
+++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java       
2006-12-15 22:07:25 UTC (rev 11427)
@@ -54,9 +54,7 @@
                return "GET, POST";
        }

-       public void handleGet(URI uri, ToadletContext ctx) throws 
ToadletContextClosedException, IOException, RedirectException {
-               final HTTPRequest request = new HTTPRequestImpl(uri);
-               
+       public void handleGet(URI uri, final HTTPRequest request, 
ToadletContext ctx) throws ToadletContextClosedException, IOException, 
RedirectException {
                String path = uri.getPath();
                if(path.endsWith("myref.fref")) {
                        SimpleFieldSet fs = node.exportPublicFieldSet();
@@ -611,14 +609,7 @@
                return (isReversed ? ("?sortBy="+type) : 
("?sortBy="+type+"&reversed"));
        }

-       public void handlePost(URI uri, Bucket data, ToadletContext ctx) throws 
ToadletContextClosedException, IOException, RedirectException {
-               if(data.size() > 1024*1024) {
-                       this.writeReply(ctx, 400, "text/plain", "Too big", "Too 
much data, darknet toadlet limited to 1MB");
-                       return;
-               }
-               
-               HTTPRequest request = new HTTPRequestImpl(uri, data, ctx);
-               
+       public void handlePost(URI uri, final HTTPRequest request, 
ToadletContext ctx) throws ToadletContextClosedException, IOException, 
RedirectException {
                boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);

                String pass = request.getPartAsString("formPassword", 32);
@@ -917,7 +908,7 @@
                        ctx.sendReplyHeaders(302, "Found", headers, null, 0);
                        return;
                } else {
-                       this.handleGet(uri, ctx);
+                       this.handleGet(uri, new HTTPRequestImpl(uri), ctx);
                }
        }


Modified: trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyToadlet.java   2006-12-15 
21:59:26 UTC (rev 11426)
+++ trunk/freenet/src/freenet/clients/http/FProxyToadlet.java   2006-12-15 
22:07:25 UTC (rev 11427)
@@ -69,7 +69,7 @@
                return "GET";
        }

-       public void handlePost(URI uri, Bucket data, ToadletContext ctx) throws 
ToadletContextClosedException, IOException, RedirectException {
+       public void handlePost(URI uri, HTTPRequest req, ToadletContext ctx) 
throws ToadletContextClosedException, IOException, RedirectException {
                String ks = uri.getPath();

                if (ks.equals("/")||ks.startsWith("/servlet/")) {
@@ -249,13 +249,11 @@
                return false;
        }

-       public void handleGet(URI uri, ToadletContext ctx) 
+       public void handleGet(URI uri, HTTPRequest httprequest, ToadletContext 
ctx) 
                        throws ToadletContextClosedException, IOException, 
RedirectException {
                //String ks = uri.toString();
                String ks = uri.getPath();

-               HTTPRequest httprequest = new HTTPRequestImpl(uri);
-               
                if (ks.equals("/")) {
                        if (httprequest.isParameterSet("key")) {
                                MultiValueTable headers = new MultiValueTable();

Modified: trunk/freenet/src/freenet/clients/http/LocalFileInsertToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/LocalFileInsertToadlet.java  
2006-12-15 21:59:26 UTC (rev 11426)
+++ trunk/freenet/src/freenet/clients/http/LocalFileInsertToadlet.java  
2006-12-15 22:07:25 UTC (rev 11427)
@@ -37,9 +37,7 @@
         * @see freenet.clients.http.Toadlet#handleGet(java.net.URI,
         *      freenet.clients.http.ToadletContext)
         */
-       public void handleGet(URI uri, ToadletContext toadletContext) throws 
ToadletContextClosedException, IOException, RedirectException {
-               HTTPRequest request = new HTTPRequestImpl(uri, null, 
toadletContext);
-
+       public void handleGet(URI uri, HTTPRequest request, ToadletContext 
toadletContext) throws ToadletContextClosedException, IOException, 
RedirectException {
                String path = request.getParam("path");
                if (path.length() == 0) {
                        if (currentPath == null) {

Modified: trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java    2006-12-15 
21:59:26 UTC (rev 11426)
+++ trunk/freenet/src/freenet/clients/http/N2NTMToadlet.java    2006-12-15 
22:07:25 UTC (rev 11427)
@@ -42,8 +42,7 @@
     return "GET, POST";
   }

-  public void handleGet(URI uri, ToadletContext ctx) throws 
ToadletContextClosedException, IOException, RedirectException {
-         HTTPRequest request = new HTTPRequestImpl(uri, null, ctx);
+  public void handleGet(URI uri, HTTPRequest request, ToadletContext ctx) 
throws ToadletContextClosedException, IOException, RedirectException {
          if (request.isParameterSet("peernode_hashcode")) {
                  HTMLNode pageNode = ctx.getPageMaker().getPageNode("Send Node 
to Node Text Message");
                  HTMLNode contentNode = 
ctx.getPageMaker().getContentNode(pageNode);
@@ -101,14 +100,7 @@
          return infobox;
   }

-  public void handlePost(URI uri, Bucket data, ToadletContext ctx) throws 
ToadletContextClosedException, IOException, RedirectException {
-         if(data.size() > 5*1024) {
-                 this.writeReply(ctx, 400, "text/plain", "Too big", "Too much 
data, N2NTM toadlet limited to 5KB");
-                 return;
-         }
-         
-         HTTPRequest request = new HTTPRequestImpl(uri, data, ctx);
-         
+  public void handlePost(URI uri, HTTPRequest request, ToadletContext ctx) 
throws ToadletContextClosedException, IOException, RedirectException {
          String pass = request.getPartAsString("formPassword", 32);
          if((pass == null) || !pass.equals(core.formPassword)) {
                  MultiValueTable headers = new MultiValueTable();

Modified: trunk/freenet/src/freenet/clients/http/PluginToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/PluginToadlet.java   2006-12-15 
21:59:26 UTC (rev 11426)
+++ trunk/freenet/src/freenet/clients/http/PluginToadlet.java   2006-12-15 
22:07:25 UTC (rev 11427)
@@ -63,9 +63,7 @@
         * @param ctx
         *            The context of this toadlet
         */
-       public void handleGet(URI uri, ToadletContext ctx) throws 
ToadletContextClosedException, IOException, RedirectException {
-               HTTPRequest httpRequest = new HTTPRequestImpl(uri, null, ctx);
-
+       public void handleGet(URI uri, HTTPRequest httpRequest, ToadletContext 
ctx) throws ToadletContextClosedException, IOException, RedirectException {
                String uriPath = uri.getPath();
                String pluginName = uriPath.substring(uriPath.lastIndexOf('/') 
+ 1);

@@ -102,9 +100,7 @@
        /**
         * @see freenet.clients.http.Toadlet#handlePost(java.net.URI, 
freenet.support.api.Bucket, freenet.clients.http.ToadletContext)
         */
-       public void handlePost(URI uri, Bucket data, ToadletContext ctx) throws 
ToadletContextClosedException, IOException, RedirectException {
-               HTTPRequest httpRequest = new HTTPRequestImpl(uri, data, ctx);
-               
+       public void handlePost(URI uri, HTTPRequest httpRequest, ToadletContext 
ctx) throws ToadletContextClosedException, IOException, RedirectException {
                String uriPath = uri.getPath();
                String pluginName = uriPath.substring(uriPath.lastIndexOf('/') 
+ 1);


Modified: trunk/freenet/src/freenet/clients/http/PproxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/PproxyToadlet.java   2006-12-15 
21:59:26 UTC (rev 11426)
+++ trunk/freenet/src/freenet/clients/http/PproxyToadlet.java   2006-12-15 
22:07:25 UTC (rev 11427)
@@ -33,11 +33,9 @@
                return "GET, POST";
        }

-       public void handlePost(URI uri, Bucket data, ToadletContext ctx)
+       public void handlePost(URI uri, HTTPRequest request, ToadletContext ctx)
                throws ToadletContextClosedException, IOException {

-               HTTPRequest request = new HTTPRequestImpl(uri, data, ctx);
-               
                MultiValueTable headers = new MultiValueTable();

                String pass = request.getPartAsString("formPassword", 32);
@@ -116,10 +114,9 @@

        }

-       public void handleGet(URI uri, ToadletContext ctx)
+       public void handleGet(URI uri, HTTPRequest request, ToadletContext ctx)
                        throws ToadletContextClosedException, IOException {
                //String basepath = "/plugins/";
-               HTTPRequest request = new HTTPRequestImpl(uri);
                String path = request.getPath();

                // remove leading / and 'plugins/' from path

Modified: trunk/freenet/src/freenet/clients/http/QueueToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/QueueToadlet.java    2006-12-15 
21:59:26 UTC (rev 11426)
+++ trunk/freenet/src/freenet/clients/http/QueueToadlet.java    2006-12-15 
22:07:25 UTC (rev 11427)
@@ -71,8 +71,7 @@
                if(fcp == null) throw new NullPointerException();
        }

-       public void handlePost(URI uri, Bucket data, ToadletContext ctx) throws 
ToadletContextClosedException, IOException, RedirectException {
-               HTTPRequest request = new HTTPRequestImpl(uri, data, ctx);
+       public void handlePost(URI uri, HTTPRequest request, ToadletContext 
ctx) throws ToadletContextClosedException, IOException, RedirectException {
                try {
                        // Browse... button
                        if (request.getPartAsString("insert-local", 
128).length() > 0) {
@@ -272,7 +271,7 @@
                } finally {
                        request.freeParts();
                }
-               this.handleGet(uri, ctx);
+               this.handleGet(uri, new HTTPRequestImpl(uri), ctx);
        }

        private void writeError(String header, String message, ToadletContext 
context) throws ToadletContextClosedException, IOException {
@@ -287,7 +286,7 @@
                writeReply(context, 400, "text/html; charset=utf-8", "Error", 
pageNode.generate());
        }

-       public void handleGet(URI uri, ToadletContext ctx) 
+       public void handleGet(URI uri, final HTTPRequest request, 
ToadletContext ctx) 
        throws ToadletContextClosedException, IOException, RedirectException {

                // We ensure that we have a FCP server running
@@ -296,7 +295,6 @@
                        return;
                }

-               final HTTPRequest request = new HTTPRequestImpl(uri, null, ctx);
                final String requestPath = 
request.getPath().substring("/queue/".length());

                if (requestPath.length() > 0) {

Modified: trunk/freenet/src/freenet/clients/http/StaticToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StaticToadlet.java   2006-12-15 
21:59:26 UTC (rev 11426)
+++ trunk/freenet/src/freenet/clients/http/StaticToadlet.java   2006-12-15 
22:07:25 UTC (rev 11427)
@@ -8,6 +8,7 @@
 import freenet.client.DefaultMIMETypes;
 import freenet.client.HighLevelSimpleClient;
 import freenet.support.api.Bucket;
+import freenet.support.api.HTTPRequest;

 /**
  * Static Toadlet.
@@ -21,7 +22,7 @@
        private static final String ROOT_URL = "/static/";
        private static final String ROOT_PATH = "staticfiles/";

-       public void handleGet(URI uri, ToadletContext ctx) throws 
ToadletContextClosedException, IOException {
+       public void handleGet(URI uri, HTTPRequest request, ToadletContext ctx) 
throws ToadletContextClosedException, IOException {
                String path = uri.getPath();

                if (!path.startsWith(ROOT_URL)) {

Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java       
2006-12-15 21:59:26 UTC (rev 11426)
+++ trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java       
2006-12-15 22:07:25 UTC (rev 11427)
@@ -21,6 +21,7 @@
 import freenet.support.HTMLNode;
 import freenet.support.SizeUtil;
 import freenet.support.TimeUtil;
+import freenet.support.api.HTTPRequest;

 public class StatisticsToadlet extends Toadlet {

@@ -80,7 +81,7 @@
                return count;
        }

-       public void handleGet(URI uri, ToadletContext ctx) throws 
ToadletContextClosedException, IOException, RedirectException {
+       public void handleGet(URI uri, HTTPRequest request, ToadletContext ctx) 
throws ToadletContextClosedException, IOException, RedirectException {

                final boolean advancedEnabled = node.isAdvancedDarknetEnabled();


Modified: trunk/freenet/src/freenet/clients/http/SymlinkerToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/SymlinkerToadlet.java        
2006-12-15 21:59:26 UTC (rev 11426)
+++ trunk/freenet/src/freenet/clients/http/SymlinkerToadlet.java        
2006-12-15 22:07:25 UTC (rev 11427)
@@ -13,6 +13,7 @@
 import freenet.config.SubConfig;
 import freenet.node.Node;
 import freenet.support.Logger;
+import freenet.support.api.HTTPRequest;

 public class SymlinkerToadlet extends Toadlet {

@@ -110,7 +111,7 @@
                return "GET";
        }

-       public void handleGet(URI uri, ToadletContext ctx)
+       public void handleGet(URI uri, HTTPRequest request, ToadletContext ctx)
        throws ToadletContextClosedException, IOException, RedirectException {
                String path = uri.getPath();
                String foundkey = null;

Modified: trunk/freenet/src/freenet/clients/http/Toadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/Toadlet.java 2006-12-15 21:59:26 UTC 
(rev 11426)
+++ trunk/freenet/src/freenet/clients/http/Toadlet.java 2006-12-15 22:07:25 UTC 
(rev 11427)
@@ -17,6 +17,7 @@
 import freenet.support.HTMLNode;
 import freenet.support.MultiValueTable;
 import freenet.support.api.Bucket;
+import freenet.support.api.HTTPRequest;

 /**
  * Replacement for servlets. Just an easy to use HTTP interface, which is
@@ -51,18 +52,18 @@
         * @throws IOException 
         * @throws ToadletContextClosedException 
         */
-       public void handleGet(URI uri, ToadletContext ctx) throws 
ToadletContextClosedException, IOException, RedirectException {
+       public void handleGet(URI uri, HTTPRequest req, ToadletContext ctx) 
throws ToadletContextClosedException, IOException, RedirectException {
                handleUnhandledRequest(uri, null, ctx);
        }

        /**
         * Likewise for a PUT request.
         */
-       public void handlePut(URI uri, Bucket data, ToadletContext ctx) throws 
ToadletContextClosedException, IOException, RedirectException {
+       public void handlePut(URI uri, ToadletContext ctx) throws 
ToadletContextClosedException, IOException, RedirectException {
                handleUnhandledRequest(uri, null, ctx);
        }

-       public void handlePost(URI uri, Bucket data, ToadletContext ctx) throws 
ToadletContextClosedException, IOException, RedirectException {
+       public void handlePost(URI uri, HTTPRequest req, ToadletContext ctx) 
throws ToadletContextClosedException, IOException, RedirectException {
                handleUnhandledRequest(uri, null, ctx);
        }


Modified: trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java      
2006-12-15 21:59:26 UTC (rev 11426)
+++ trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java      
2006-12-15 22:07:25 UTC (rev 11427)
@@ -288,7 +288,7 @@

                                        if(method.equals("GET")) {
                                                try {
-                                                       t.handleGet(uri, ctx);
+                                                       t.handleGet(uri, new 
HTTPRequestImpl(uri), ctx);
                                                        ctx.close();
                                                } catch (RedirectException re) {
                                                        uri = re.newuri;
@@ -297,7 +297,7 @@

                                        } else if(method.equals("PUT")) {
                                                try {
-                                                       t.handlePut(uri, null, 
ctx);
+                                                       t.handlePut(uri, ctx);
                                                        ctx.close();
                                                } catch (RedirectException re) {
                                                        uri = re.newuri;
@@ -306,7 +306,7 @@

                                        } else if(method.equals("POST")) {
                                                try {
-                                                       t.handlePost(uri, data, 
ctx);
+                                                       t.handlePost(uri, new 
HTTPRequestImpl(uri, data, ctx), ctx);
                                                } catch (RedirectException re) {
                                                        uri = re.newuri;
                                                        redirect = true;


Reply via email to