*** mod_servlet.c.orig Fri Jun 6 01:56:13 1997 --- mod_servlet.c Wed Jun 11 23:51:52 1997 *************** *** 62,67 **** --- 62,69 ---- ** PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ** ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR ** DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. + ** + ** Tweaked for Apache 1.2.0 by */ *************** *** 86,92 **** #define SERVLET_CONFIG "/opt/local/pkgs/ServAPI/servlets.properties" #endif #ifndef NCGI_CLASS ! #define NCGI_CLASS "sun.servlet.embedding.ncgi.NcgiServletGate" #endif #ifndef NCGI_HOST #define NCGI_HOST "localhost" --- 88,94 ---- #define SERVLET_CONFIG "/opt/local/pkgs/ServAPI/servlets.properties" #endif #ifndef NCGI_CLASS ! #define NCGI_CLASS "sun.servlet.apache.NcgiServletGate" #endif #ifndef NCGI_HOST #define NCGI_HOST "localhost" *************** *** 498,504 **** /* ServletConfig command. */ ! static char* servlet_config( cmd_parms* parms, void* dummy, char* var, char* val ) { server_rec* s = parms->server; --- 500,506 ---- /* ServletConfig command. */ ! const char* servlet_config( cmd_parms* parms, void* dummy, char* var, char* val ) { server_rec* s = parms->server; *************** *** 546,552 **** /* Request handler. Called on each request. */ static int servlet_handler( request_rec* r ) ! { static int inited = 0; server_rec* s = r->server; table* e = r->subprocess_env; --- 548,554 ---- /* Request handler. Called on each request. */ static int servlet_handler( request_rec* r ) ! { static int inited = 0; server_rec* s = r->server; table* e = r->subprocess_env; *************** *** 560,565 **** --- 562,568 ---- char databuffer[HUGE_STRING_LEN]; int path_info_start; char* path_info_str; + int retval; /* Initialize if necessary. We call the init routine from the request ** handler rather than via the init entry in the module struct because *************** *** 608,613 **** --- 611,622 ---- return SERVER_ERROR; } + /* No chunked requests via our NCGI interface, sorry folks */ + if((retval = setup_client_block(r, REQUEST_CHUNKED_ERROR)) != OK) { + cleanup_handler( r, sock, handler ); + return retval; + } + /* Make a CGI environment array. */ add_common_vars( r ); *************** *** 619,629 **** /* Adjusting variables for servlet location */ ! table_set (e, "GATEWAY_INTERFACE","servlet"); table_set (e, "SERVER_PROTOCOL", r->protocol); table_set (e, "REQUEST_METHOD", r->method); table_set (e, "QUERY_STRING", r->args ? r->args : ""); if (strncmp(r->uri,"/servlet/",strlen("/servlet/"))) { log_reason( "servlets must be in /servlet directory", r->uri, r ); cleanup_handler( r, sock, handler ); --- 628,643 ---- /* Adjusting variables for servlet location */ ! table_set (e, "GATEWAY_INTERFACE", "servlet"); table_set (e, "SERVER_PROTOCOL", r->protocol); table_set (e, "REQUEST_METHOD", r->method); table_set (e, "QUERY_STRING", r->args ? r->args : ""); + /* This hardcode of /servlet/ is an offense against all + * that is right and good... but it's very pervasive and + * I can't get rid of it without tweaking all kinds of + * code. + */ if (strncmp(r->uri,"/servlet/",strlen("/servlet/"))) { log_reason( "servlets must be in /servlet directory", r->uri, r ); cleanup_handler( r, sock, handler ); *************** *** 633,639 **** /* someone is trying to get to the "servlets directory". tsk.*/ cleanup_handler( r, sock, handler ); return FORBIDDEN; ! } /* length = total - path_info + strlen("/servlet/") */ --- 647,653 ---- /* someone is trying to get to the "servlets directory". tsk.*/ cleanup_handler( r, sock, handler ); return FORBIDDEN; ! } /* length = total - path_info + strlen("/servlet/") */ *************** *** 685,725 **** ** on every invocation by chasing the real client data with a ** spurious newline). */ ! if ( r->method_number == M_POST || r->method_number == M_PUT ) { ! int remaining = atoi( lenp ); ! int ok_to_write = 1; ! ! while ( remaining > 0 ) { ! int len_read, len_to_read = remaining; ! if ( len_to_read > sizeof(databuffer) ) ! len_to_read = sizeof(databuffer); ! len_read = read_client_block( r, databuffer, len_to_read ); ! if ( len_read == 0 ) break; - if ( ok_to_write ) - if ( write( sock, databuffer, len_read ) < 0 ) - ok_to_write = 0; - remaining -= len_read; } } /* Send back the results. */ bflush( r->connection->client ); ! for (;;) ! { int len_read = read( sock, databuffer, sizeof(databuffer) ); if ( len_read <= 0 ) break; if ( write( r->connection->client->fd, databuffer, len_read ) <= 0 ) break; ! } /* All done. */ cleanup_handler( r, sock, handler ); return OK; /* NOT r->status, even if it has changed */ ! } /* Command table. */ --- 699,740 ---- ** on every invocation by chasing the real client data with a ** spurious newline). */ ! ! if(should_client_block(r)) ! { ! int len_read; ! ! while((len_read = ! get_client_block(r, databuffer, HUGE_STRING_LEN)) > 0) { ! ! reset_timeout(r); ! if(write(sock, databuffer, len_read) < (size_t)len_read) { ! /* script stopped reading */ ! while(get_client_block(r, databuffer, HUGE_STRING_LEN) > 0) ! ; /* dump read data */ break; } } + kill_timeout(r); + } + /* Send back the results. */ bflush( r->connection->client ); ! for (;;) { int len_read = read( sock, databuffer, sizeof(databuffer) ); if ( len_read <= 0 ) break; if ( write( r->connection->client->fd, databuffer, len_read ) <= 0 ) break; ! } /* All done. */ cleanup_handler( r, sock, handler ); return OK; /* NOT r->status, even if it has changed */ ! } /* Command table. */