osrfLogDebug(OSRF_LOG_MARK, "gateway entering ap_get_client_block loop");
- while(ap_get_client_block(r, body, 1024)) {
+ long bread;
+ while( (bread = ap_get_client_block(r, body, 1024)) ) {
buffer_add( buffer, body );
memset(body,0,1025);
osrfLogDebug(OSRF_LOG_MARK,
- "gateway read %d bytes of data so far", buffer->n_used);
+ "gateway read %d bytes: %d bytes of data so far", bread, buffer->n_used);
+
+ /* this seems unnecessary since ap_get_client_block is supposed
+ * to return 0 when no data is read, but somehow we are getting
+ * here with 0 bytes of data in the buffer */
+ if(buffer->n_used == 0) {
+ osrfLogInfo(OSRF_LOG_MARK, "buffer->n_used == 0 but we're in the read loop...");
+ break;
+ }
if(buffer->n_used > APACHE_TOOLS_MAX_POST_SIZE) {
osrfLogError(OSRF_LOG_MARK, "gateway received POST larger "
arg = (char*) apr_pstrdup(p, tmp_buf->buf);
buffer_free(tmp_buf);
- } else {
- arg = (char*) apr_pstrdup(p, buffer->buf);
+ } else if(buffer->n_used > 0){
+ arg = (char*) apr_pstrdup(p, buffer->buf);
+
+ } else {
+ arg = NULL;
}
buffer_free(buffer);
osrfLogDebug(OSRF_LOG_MARK, "gateway done mangling post data");
- if( ! arg || !arg[0] ) { /* we received no request */
+ if( !arg || !arg[0] ) { /* we received no request */
return NULL;
}