summaryrefslogtreecommitdiff
path: root/sapi/thttpd
diff options
context:
space:
mode:
authorSascha Schumann <sas@php.net>2001-10-27 12:08:10 +0000
committerSascha Schumann <sas@php.net>2001-10-27 12:08:10 +0000
commit1f6f91035ebcd6c821033c1907823c87ffc7fc5b (patch)
treeaf8f8f39cadb20b9d457633fbfd727cffac16175 /sapi/thttpd
parenta3368ababa55ab8bded1232007998a2c341d1bc4 (diff)
downloadphp-git-1f6f91035ebcd6c821033c1907823c87ffc7fc5b.tar.gz
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.
Diffstat (limited to 'sapi/thttpd')
-rw-r--r--sapi/thttpd/thttpd.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c
index e6dcb2df38..ee8fb19c71 100644
--- a/sapi/thttpd/thttpd.c
+++ b/sapi/thttpd/thttpd.c
@@ -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 @@ static int sapi_thttpd_read_post(char *buffer, uint count_bytes TSRMLS_DC)
}
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 @@ static int sapi_thttpd_read_post(char *buffer, uint count_bytes TSRMLS_DC)
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 @@ static void thttpd_request_ctor(TSRMLS_D)
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 @@ static off_t thttpd_real_php_request(httpd_conn *hc TSRMLS_DC)
TG(hc) = hc;
hc->bytes_sent = 0;
+ TG(read_post_data) = 0;
if (hc->method == METHOD_POST)
hc->should_linger = 1;