Project

General

Profile

Bug #343 ยป fastcgi-cont3.patch

Yehuda Sadeh, 09/03/2010 04:49 PM

View differences:

mod_fastcgi-SNAP-0910052141/fcgi.h 2010-09-03 17:12:57.000000000 -0700
char *fs_stderr;
int fs_stderr_len;
int parseHeader; /* TRUE iff parsing response headers */
int gotCont;
request_rec *r;
int readingEndRequestBody;
FCGI_EndRequestBody endRequestBody;
......
*/
void fcgi_protocol_queue_begin_request(fcgi_request *fr);
void fcgi_protocol_queue_client_buffer(fcgi_request *fr);
int fcgi_protocol_queue_env(request_rec *r, fcgi_request *fr, env_status *env);
int fcgi_protocol_queue_env(request_rec *r, fcgi_request *fr, env_status *env, int *expect_cont);
int fcgi_protocol_dequeue(pool *p, fcgi_request *fr);
/*
mod_fastcgi-SNAP-0910052141/fcgi_protocol.c 2010-09-03 17:13:39.000000000 -0700
* complete ENV was buffered, FALSE otherwise. Note: envp is updated to
* reflect the current position in the ENV.
*/
int fcgi_protocol_queue_env(request_rec *r, fcgi_request *fr, env_status *env)
int fcgi_protocol_queue_env(request_rec *r, fcgi_request *fr, env_status *env,
int *expect_cont)
{
int charCount;
const char *name, *val;
if (env->envp == NULL) {
ap_add_common_vars(r);
......
env->envp = ap_create_environment(r->pool, r->subprocess_env);
env->pass = PREP;
}
*expect_cont = 0;
while (*env->envp) {
ap_log_error(FCGI_LOG_WARN_NOERRNO, fcgi_apache_main_server,
"FastCGI: JJJ envp=%s", *env->envp);
switch (env->pass)
{
case PREP:
env->equalPtr = strchr(*env->envp, '=');
ASSERT(env->equalPtr != NULL);
name = *env->envp;
val = env->equalPtr + 1;
env->nameLen = env->equalPtr - *env->envp;
env->valueLen = strlen(++env->equalPtr);
ap_log_error(FCGI_LOG_WARN_NOERRNO, fcgi_apache_main_server,
"FastCGI: JJJ name='%.*s' val='%.*s'", env->nameLen, *env->envp, env->valueLen, val);
if (val && env->nameLen == sizeof("HTTP_EXPECT") - 1 &&
strncasecmp(name, "HTTP_EXPECT", env->nameLen) == 0 &&
strncasecmp(val, "100-continue", env->valueLen) == 0)
*expect_cont = 1;
build_env_header(env->nameLen, env->valueLen, env->headerBuff, &env->headerLen);
env->totalLen = env->headerLen + env->nameLen + env->valueLen;
env->pass = HEADER;
mod_fastcgi-SNAP-0910052141/mod_fastcgi.c 2010-09-03 17:24:16.000000000 -0700
static const char *process_headers(request_rec *r, fcgi_request *fr)
{
char *p, *next, *name, *value;
int len, flag;
int len, flag, newl;
int hasLocation = FALSE;
ASSERT(fr->parseHeader == SCAN_CGI_READING_HEADERS);
......
p = (char *)fr->header->elts;
len = fr->header->nelts;
flag = 0;
newl = 1;
while(len-- && flag < 2) {
switch(*p) {
if (newl && !fr->gotCont && strncasecmp(p, "Status: 100", 11) == 0) {
fr->gotCont = 1;
ap_log_error(FCGI_LOG_WARN_NOERRNO, fcgi_apache_main_server,
"FastCGI: JJJ gotCont=1");
}
switch(*p) {
case '\r':
break;
case '\n':
newl = 1;
flag++;
break;
case '\0':
......
name = "Invalid Character";
goto BadHeader;
default:
newl = 0;
flag = 0;
break;
}
......
pool * const rp = r->pool;
int is_connected = 0;
DWORD recv_count = 0;
int expect_cont = 0;
dynamic_last_io_time.tv_sec = 0;
dynamic_last_io_time.tv_usec = 0;
......
{
case STATE_ENV_SEND:
if (fcgi_protocol_queue_env(r, fr, &env_status) == 0)
if (fcgi_protocol_queue_env(r, fr, &env_status, &expect_cont) == 0)
{
goto SERVER_SEND;
}
......
env_status env;
pool *rp = r->pool;
int is_connected = 0;
int expect_cont = 0;
dynamic_last_io_time.tv_sec = 0;
dynamic_last_io_time.tv_usec = 0;
......
{
case STATE_ENV_SEND:
if (fcgi_protocol_queue_env(r, fr, &env) == 0)
if (fcgi_protocol_queue_env(r, fr, &env, &expect_cont) == 0)
{
goto SERVER_SEND;
}
......
/* fall through */
case STATE_CLIENT_RECV:
if (expect_cont && !fr->gotCont) {
goto SERVER_SEND;
}
if (read_from_client_n_queue(fr))
{
......
state = STATE_ERROR;
break;
}
if (expect_cont && fr->gotCont) {
state = STATE_CLIENT_RECV;
continue;
}
}
if (fr->exitStatusSet)
    (1-1/1)