diff options
author | Sascha Schumann <sas@php.net> | 2002-10-30 19:09:49 +0000 |
---|---|---|
committer | Sascha Schumann <sas@php.net> | 2002-10-30 19:09:49 +0000 |
commit | 55879b354325e0f072a845bf49fff00d647f73a1 (patch) | |
tree | c0be584cb6adf18b568271329ee17e88235660ae /sapi/thttpd/thttpd.c | |
parent | 6514fac1c01c609c04609337290ab4de2e94f24f (diff) | |
download | php-git-55879b354325e0f072a845bf49fff00d647f73a1.tar.gz |
first step towards asynchronous content body processing
Diffstat (limited to 'sapi/thttpd/thttpd.c')
-rw-r--r-- | sapi/thttpd/thttpd.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/sapi/thttpd/thttpd.c b/sapi/thttpd/thttpd.c index 5b1940c670..ae8e47d12a 100644 --- a/sapi/thttpd/thttpd.c +++ b/sapi/thttpd/thttpd.c @@ -212,18 +212,22 @@ static int sapi_thttpd_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC) return SAPI_HEADER_SENT_SUCCESSFULLY; } +/* to understand this, read cgi_interpose_input() in libhttpd.c */ +#define SIZEOF_UNCONSUMED_BYTES() (TG(hc)->read_idx - TG(hc)->checked_idx) +#define CONSUME_BYTES(n) do { TG(hc)->checked_idx += (n); } while (0) + + static int sapi_thttpd_read_post(char *buffer, uint count_bytes TSRMLS_DC) { size_t read_bytes = 0, tmp; int c; int n; - /* to understand this, read cgi_interpose_input() in libhttpd.c */ - c = TG(hc)->read_idx - TG(hc)->checked_idx; + c = SIZEOF_UNCONSUMED_BYTES(); if (c > 0) { read_bytes = MIN(c, count_bytes); memcpy(buffer, TG(hc)->read_buf + TG(hc)->checked_idx, read_bytes); - TG(hc)->checked_idx += read_bytes; + CONSUME_BYTES(read_bytes); count_bytes -= read_bytes; } @@ -644,6 +648,8 @@ static void remove_dead_conn(int fd) #endif +#define CT_LEN_MAX_RAM 8192 + static off_t thttpd_real_php_request(httpd_conn *hc, int show_source TSRMLS_DC) { TG(hc) = hc; @@ -653,6 +659,18 @@ static off_t thttpd_real_php_request(httpd_conn *hc, int show_source TSRMLS_DC) if (hc->method == METHOD_POST) hc->should_linger = 1; + if (hc->contentlength > 0 + && SIZEOF_UNCONSUMED_BYTES() < hc->contentlength) { + int missing = hc->contentlength - SIZEOF_UNCONSUMED_BYTES(); + + if (hc->contentlength < CT_LEN_MAX_RAM) { + hc->read_body_into_mem = 1; + return 0; + } else { + return -1; + } + } + thttpd_request_ctor(TSRMLS_C); thttpd_module_main(show_source TSRMLS_CC); |