dblevins 2004/12/22 00:42:39
Modified: modules/core/src/java/org/openejb/server/httpd
HttpRequestImpl.java HttpServer.java
Log:
Basic soap rpc/encoded deployment and container support along with a general
revamping of the networkservice stacks.
Revision Changes Path
1.3 +11 -6
openejb/modules/core/src/java/org/openejb/server/httpd/HttpRequestImpl.java
Index: HttpRequestImpl.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/server/httpd/HttpRequestImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HttpRequestImpl.java 20 Dec 2004 06:56:41 -0000 1.2
+++ HttpRequestImpl.java 22 Dec 2004 05:42:38 -0000 1.3
@@ -90,7 +90,7 @@
* the content of the body of this page
*/
private byte[] body;
- private DataInput in;
+ private InputStream in;
private int length;
private String contentType;
@@ -192,7 +192,7 @@
}
public InputStream getInputStream() throws IOException {
- return (InputStream) this.in;
+ return this.in;
}
/*------------------------------------------------------------*/
@@ -386,7 +386,7 @@
contentType = getHeader(HttpRequest.HEADER_CONTENT_TYPE);
- if (FORM_URL_ENCODED.equals(contentType)) {
+ if (method == POST && FORM_URL_ENCODED.equals(contentType)) {
String rawParams = null;
try {
@@ -422,9 +422,15 @@
formParams.put(name, value);
//System.out.println(name + ": " + value);
}
+ } else if (method == POST){
+ // TODO This really is terrible
+ byte[] body = new byte[length];
+ in.readFully(body);
+ this.in = new ByteArrayInputStream(body);
} else {
- this.in = in;
+ this.in = new ByteArrayInputStream(new byte[0]);
}
+
}
private int parseContentLength() {
@@ -476,5 +482,4 @@
public HttpSession getSession() {
return getSession(true);
}
-
}
1.3 +8 -1
openejb/modules/core/src/java/org/openejb/server/httpd/HttpServer.java
Index: HttpServer.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/server/httpd/HttpServer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HttpServer.java 19 Dec 2004 06:17:15 -0000 1.2
+++ HttpServer.java 22 Dec 2004 05:42:38 -0000 1.3
@@ -47,6 +47,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.PrintWriter;
import java.net.Socket;
import java.net.URL;
import java.util.Properties;
@@ -65,6 +66,7 @@
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanLifecycle;
import org.apache.geronimo.gbean.WaitingException;
+import sun.net.www.protocol.http.HttpURLConnection;
/**
* This is the main class for the web administration. It takes care of the
@@ -188,6 +190,11 @@
req.readMessage(in);
res.setRequest(req);
} catch (Throwable t) {
+ res.setCode(HttpURLConnection.HTTP_BAD_REQUEST);
+ res.setResponseString("Could not read the request");
+ res.getPrintWriter().println(t.getMessage());
+ t.printStackTrace(res.getPrintWriter());
+ log.error("BAD REQUEST", t);
throw new OpenEJBException("Could not read the request.\n" +
t.getClass().getName() + ":\n" + t.getMessage(), t);
}