[freenet-cvs] r12528 - in trunk/freenet/src/freenet: clients/http pluginmanager

nextgens at freenetproject.org nextgens at freenetproject.org
Mon Apr 2 18:54:57 UTC 2007


Author: nextgens
Date: 2007-04-02 18:54:57 +0000 (Mon, 02 Apr 2007)
New Revision: 12528

Modified:
   trunk/freenet/src/freenet/clients/http/PproxyToadlet.java
   trunk/freenet/src/freenet/pluginmanager/PluginHTTPException.java
Log:
Extend the plugin framework a bit... maybe I need to do .getByte("UTF-8") though... I don't know

Modified: trunk/freenet/src/freenet/clients/http/PproxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/PproxyToadlet.java	2007-04-02 18:19:36 UTC (rev 12527)
+++ trunk/freenet/src/freenet/clients/http/PproxyToadlet.java	2007-04-02 18:54:57 UTC (rev 12528)
@@ -74,10 +74,10 @@
 			catch(PluginHTTPException ex)
 			{
 				// TODO: make it into html
-				if((ex.getCode() < 400) && (ex.getCode() >= 300)) {
-					headers = new MultiValueTable();
-					headers.put("Location", ex.getReply());
-					ctx.sendReplyHeaders(ex.getCode(), "Found", headers, null, 0);
+				if(ex.getHeaders() != null) {
+					String data = ex.getReply();
+					ctx.sendReplyHeaders(ex.getCode(), "Found", ex.getHeaders(), ex.getMimeType(), (data == null ? 0 : data.length()));
+					ctx.writeData(data.getBytes());
 				}else
 					writeReply(ctx, ex.getCode(), ex.getMimeType(), ex.getDesc(), ex.getReply());
 			}
@@ -209,10 +209,10 @@
 			
 		} catch (PluginHTTPException ex) {
 			// TODO: make it into html
-			if((ex.getCode() < 400) && (ex.getCode() >= 300)) {
-				MultiValueTable headers = new MultiValueTable();
-				headers.put("Location", ex.getReply());
-				ctx.sendReplyHeaders(ex.getCode(), "Found", headers, null, 0);
+			if(ex.getHeaders() != null) {
+				String data = ex.getReply();
+				ctx.sendReplyHeaders(ex.getCode(), "Found", ex.getHeaders(), ex.getMimeType(), (data == null ? 0 : data.length()));
+				ctx.writeData(data.getBytes());
 			}else
 				writeReply(ctx, ex.getCode(), ex.getMimeType(), ex.getDesc(), ex.getReply());
 		} catch (Throwable t) {

Modified: trunk/freenet/src/freenet/pluginmanager/PluginHTTPException.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/PluginHTTPException.java	2007-04-02 18:19:36 UTC (rev 12527)
+++ trunk/freenet/src/freenet/pluginmanager/PluginHTTPException.java	2007-04-02 18:54:57 UTC (rev 12528)
@@ -3,6 +3,8 @@
  * http://www.gnu.org/ for further details of the GPL. */
 package freenet.pluginmanager;
 
+import freenet.support.MultiValueTable;
+
 public class PluginHTTPException extends Exception {
 	private static final long serialVersionUID = -1;
 	
@@ -10,7 +12,7 @@
 	private String mimeType;
 	private String desc;
 	private String reply;
-	
+	private MultiValueTable headers = null;
 
 	public PluginHTTPException () {
 		this(404, "text/html", "FAIL", "Page not found");
@@ -21,6 +23,14 @@
 		this.desc = desc;
 		this.reply = reply;
 	}
+
+	public PluginHTTPException (int code, String desc, MultiValueTable headers, String mimeType, String reply) {
+		this.code = code;
+		this.desc = desc;
+		this.headers = headers;
+		this.mimeType = mimeType;
+		this.reply = reply;
+	}
 	
 	public void setCode(int code) {
 		// FIXME: check!
@@ -47,5 +57,7 @@
 	public String getReply() {
 		return reply;
 	}
-
+	public MultiValueTable getHeaders() {
+		return headers;
+	}
 }




More information about the cvs mailing list