You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by da...@apache.org on 2001/01/05 04:39:26 UTC
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/service/connector Ajp13ConnectorRequest.java
danmil 01/01/04 19:39:26
Modified: src/native/jk Tag: tomcat_32 jk_ajp13_worker.c
src/share/org/apache/tomcat/service/connector Tag: tomcat_32
Ajp13ConnectorRequest.java
Log:
- Fixed the problems with multipart form encodings. Bug Reports #536 +
#542 and a bunch of others. File upload is now working.
- In doRead(), replaced byte-by-byte copy with System.arraycopy().
- Clarified Ajp13 protocol: if the container tries to read
past the end of the input stream, the server sends an empty packet back.
Revision Changes Path
No revision
No revision
1.3.2.2 +14 -12 jakarta-tomcat/src/native/jk/Attic/jk_ajp13_worker.c
Index: jk_ajp13_worker.c
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/native/jk/Attic/jk_ajp13_worker.c,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -u -r1.3.2.1 -r1.3.2.2
--- jk_ajp13_worker.c 2000/09/13 23:06:25 1.3.2.1
+++ jk_ajp13_worker.c 2001/01/05 03:39:25 1.3.2.2
@@ -57,7 +57,7 @@
* Description: Experimental bi-directionl protocol. *
* Author: Costin <co...@costin.dnt.ro> *
* Author: Gal Shachor <sh...@il.ibm.com> *
- * Version: $Revision: 1.3.2.1 $ *
+ * Version: $Revision: 1.3.2.2 $ *
***************************************************************************/
#include "jk_pool.h"
@@ -267,7 +267,7 @@
read_buf += 4; /* leave some space for the buffer headers */
read_buf += 2; /* leave some space for the read length */
- if(read_fully_from_server(r, read_buf, len) <= 0) {
+ if(read_fully_from_server(r, read_buf, len) < 0) {
jk_log(l, JK_LOG_ERROR,
"read_into_msg_buff: Error - read_fully_from_server failed\n");
return JK_FALSE;
@@ -331,23 +331,25 @@
case JK_AJP13_GET_BODY_CHUNK:
{
- unsigned len = (unsigned)jk_b_get_int(msg);
+ unsigned len = (unsigned)jk_b_get_int(msg);
if(len > MAX_SEND_BODY_SZ) {
len = MAX_SEND_BODY_SZ;
}
if(len > ep->left_bytes_to_send) {
len = ep->left_bytes_to_send;
- }
- if(len > 0) {
- if(read_into_msg_buff(ep, r, msg, l, len)) {
- return JK_AJP13_HAS_RESPONSE;
- }
-
- jk_log(l, JK_LOG_ERROR,
- "Error ajp13_process_callback - read_into_msg_buff failed\n");
- return JK_INTERNAL_ERROR;
}
+ if(len < 0) {
+ len = 0;
+ }
+
+ if(read_into_msg_buff(ep, r, msg, l, len)) {
+ return JK_AJP13_HAS_RESPONSE;
+ }
+
+ jk_log(l, JK_LOG_ERROR,
+ "Error ajp13_process_callback - read_into_msg_buff failed\n");
+ return JK_INTERNAL_ERROR;
}
break;
No revision
No revision
1.5.2.3 +38 -17 jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Attic/Ajp13ConnectorRequest.java
Index: Ajp13ConnectorRequest.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Attic/Ajp13ConnectorRequest.java,v
retrieving revision 1.5.2.2
retrieving revision 1.5.2.3
diff -u -r1.5.2.2 -r1.5.2.3
--- Ajp13ConnectorRequest.java 2000/12/12 09:41:43 1.5.2.2
+++ Ajp13ConnectorRequest.java 2001/01/05 03:39:25 1.5.2.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Attic/Ajp13ConnectorRequest.java,v 1.5.2.2 2000/12/12 09:41:43 hgomez Exp $
- * $Revision: 1.5.2.2 $
- * $Date: 2000/12/12 09:41:43 $
+ * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Attic/Ajp13ConnectorRequest.java,v 1.5.2.3 2001/01/05 03:39:25 danmil Exp $
+ * $Revision: 1.5.2.3 $
+ * $Date: 2001/01/05 03:39:25 $
*
* ====================================================================
*
@@ -250,24 +250,43 @@
public int doRead() throws IOException
{
if(pos >= blen) {
- refeelReadBuffer();
- }
+ if( ! refillReadBuffer()) {
+ return -1;
+ }
+ }
return bodyBuff[pos++];
}
public int doRead(byte[] b, int off, int len) throws IOException
{
- // XXXXXX Stupid, but the whole thing must be rewriten ( see super()! )
- for(int i = off ; i < (len + off) ; i++) {
- int a = doRead();
- if(-1 == a) {
- System.out.println("Y");
- return i-off;
- }
- b[i] = (byte)a;
- }
-
- return len;
+ if(pos >= blen) {
+ if( ! refillReadBuffer()) {
+ return -1;
+ }
+ }
+
+ int toCopy = len;
+ while(toCopy > 0) {
+ int bytesRemaining = blen - pos;
+ if(bytesRemaining < 0)
+ bytesRemaining = 0;
+ int c = bytesRemaining < toCopy ? bytesRemaining : toCopy;
+
+ System.arraycopy(bodyBuff, pos, b, off, c);
+
+ toCopy -= c;
+
+ off += c;
+ pos += c; // In case we exactly consume the buffer
+
+ if(toCopy > 0) {
+ if( ! refillReadBuffer()) { // Resets blen and pos
+ break;
+ }
+ }
+ }
+
+ return len - toCopy;
}
public void recycle()
@@ -283,7 +302,7 @@
this.in = new BufferedServletInputStream(this);
}
- public void refeelReadBuffer() throws IOException
+ public boolean refillReadBuffer() throws IOException
{
MsgBuffer msg = con.getMsgBuffer();
msg.appendByte(JK_AJP13_GET_BODY_CHUNK);
@@ -298,5 +317,7 @@
blen = msg.peekInt();
pos = 0;
msg.getBytes(bodyBuff);
+
+ return (blen > 0);
}
}