Update of /cvsroot/mod-c/ehtml/src
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv8013/src
Modified Files:
Request.cpp
Log Message:
Fixed large POSTs processing. ap_get_client_block() must be called more than
once.
Index: Request.cpp
===================================================================
RCS file: /cvsroot/mod-c/ehtml/src/Request.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** Request.cpp 15 Dec 2006 17:44:56 -0000 1.26
--- Request.cpp 8 Mar 2007 17:44:20 -0000 1.27
***************
*** 66,69 ****
--- 66,70 ----
{
ProfileMe();
+ int retVal = 0;
request_rec * r = RequestContext->r;
***************
*** 84,133 ****
PARSE_HEADER;
char * content = NULL;
! bool error = false;
! if (ContentType == CT_MULTIPART_FORM_DATA) {
! Debug("file upload detected");
! int length = 4095;
! ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK);
! content = new char[length+1];
! if (!ap_should_client_block(r))
! break;
! long nbytes;
! size_t used = 0;
! char state = 0; // 'f': fail, 'd': done, 'p': part, 'h' header
! char* varname = NULL;
! while (0 != (nbytes = ap_get_client_block(r,content+used,length-used))) {
! content[length] = '\0';
! used += nbytes;
! ReadSoFar += nbytes;
! Application->UploadProgressCallback();
! ProcessUploadChunk(content, used, state, varname);
! }
! delete[] content;
! content = NULL;
! } else {
! // a simple post
! long length = ContentLength > 0 ? ContentLength : 4095;
! ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK);
! if (ap_should_client_block( r ))
! {
! // if the client is about to send content
! content = new char[length + 1];
! error = ap_get_client_block( r, content, length) == 0;
! content[length] = '\0';
! }
! }
! // Did an error occur?
! if ( error )
! {
! if ( content )
! delete[] content;
! content = NULL;
! return 1;
! }
! else if ( content )
! // We have the query. Now parse it
! return ParseURLEncodedArgs( content, Arguments );
}
break;
--- 85,125 ----
PARSE_HEADER;
char * content = NULL;
! long length = ContentLength > 0 ? ContentLength: 4095;
! long nbytes;
! size_t used = 0;
! if (ContentType == CT_MULTIPART_FORM_DATA)
! Debug("file upload detected");
! if (0 != (retVal = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)))
! return -1;
!
! if (!ap_should_client_block(r))
! break;
!
! Debug("getting %ld bytes", length);
!
! content = new char[length+1];
! char state;
! char* varname;
!
! while (0 != (nbytes = ap_get_client_block(r,content+used,length-used))) {
! used += nbytes;
! content[used] = '\0';
! Debug("got %ld bytes (%lu total): %s", nbytes, used, content);
! if (ContentType == CT_MULTIPART_FORM_DATA) {
! ReadSoFar += nbytes;
! Application->UploadProgressCallback();
! ProcessUploadChunk(content, used, state, varname);
! }
! }
!
! if (ContentType == CT_APPLICATION_URLENCODED) {
! retVal = ParseURLEncodedArgs( content, Arguments );
! Debug("parsed (url-encoded) \"%s\": %d", content, retVal);
! }
!
! delete[] content;
! content = NULL;
}
break;
***************
*** 137,141 ****
}
! return 0;
}
--- 129,133 ----
}
! return retVal;
}
|