cvs: php4 /sapi/thttpd thttpd.c

From: Date: Sat, 27 Oct 2001 12:08:11 +0000
Subject: cvs: php4 /sapi/thttpd thttpd.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-7997@lists.php.net to get a copy of this message
sas Sat Oct 27 08:08:11 2001 EDT Modified files: /php4/sapi/thttpd thttpd.c Log: Get rid of post_off-hack which was only suitable for POST data which fit into the small thttpd read buffer. Do a small recv after content-length bytes have been read to accomodate non-conforming user-agents. Index: php4/sapi/thttpd/thttpd.c diff -u php4/sapi/thttpd/thttpd.c:1.60 php4/sapi/thttpd/thttpd.c:1.61 --- php4/sapi/thttpd/thttpd.c:1.60 Sat Oct 27 07:27:39 2001 +++ php4/sapi/thttpd/thttpd.c Sat Oct 27 08:08:10 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: thttpd.c,v 1.60 2001/10/27 11:27:39 sas Exp $ */ +/* $Id: thttpd.c,v 1.61 2001/10/27 12:08:10 sas Exp $ */ #include "php.h" #include "SAPI.h" @@ -32,7 +32,7 @@ typedef struct { httpd_conn *hc; - int post_off; + int read_post_data; void (*on_close)(int); } php_thttpd_globals; @@ -145,7 +145,7 @@ } count_bytes = MIN(count_bytes, - SG(request_info).content_length - SG(read_post_bytes) - TG(post_off)); + SG(request_info).content_length - SG(read_post_bytes)); while (read_bytes < count_bytes) { tmp = recv(TG(hc)->conn_fd, buffer + read_bytes, @@ -156,6 +156,16 @@ if (tmp != 0 && tmp != -1) read_bytes += tmp; } + + TG(read_post_data) += read_bytes; + + /* Hack for user-agents which send a LR or CRLF after POST data */ + if (TG(read_post_data) >= TG(hc)->contentlength) { + char tmpbuf[2]; + + /* we are in non-blocking mode */ + recv(TG(hc)->conn_fd, tmpbuf, 2, 0); + } return read_bytes; } @@ -302,16 +312,6 @@ SG(request_info).content_length = TG(hc)->contentlength; php_handle_auth_data(TG(hc)->authorization TSRMLS_CC); - - TG(post_off) = TG(hc)->read_idx - TG(hc)->checked_idx; - - /* avoid feeding \r\n from POST data to SAPI */ - offset = TG(post_off) - SG(request_info).content_length; - - if (offset > 0) { - TG(post_off) -= offset; - TG(hc)->read_idx -= offset; - } } static void thttpd_request_dtor(TSRMLS_D) @@ -504,6 +504,7 @@ TG(hc) = hc; hc->bytes_sent = 0; + TG(read_post_data) = 0; if (hc->method == METHOD_POST) hc->should_linger = 1;

« previous php.cvs (#7997) next »