diff -r php-4.0.0/main.c php-4.0.0_with_put/main.c 1023a1024,1027 > if (!_gpc_flags[0] && !SG(headers_sent) && SG(request_info).request_method && !strcasecmp(SG(request_info).request_method, "PUT")) { > php_treat_data(PARSE_PUT, NULL ELS_CC PLS_CC SLS_CC); /* PUT Data */ > _gpc_flags[0]=1; > } diff -r php-4.0.0/php_variables.h php-4.0.0_with_put/php_variables.h 41a42 > #define PARSE_PUT 4 diff -r php-4.0.0/php_variables.c php-4.0.0_with_put/php_variables.c 250a251,255 > if (arg==PARSE_PUT) { > sapi_handle_put(SLS_C); > return; > } > diff -r php-4.0.0/SAPI.h php-4.0.0_with_put/SAPI.h 134a135 > SAPI_API void sapi_handle_put(SLS_D); diff -r php-4.0.0/SAPI.c php-4.0.0_with_put/SAPI.c 31a32,34 > #include "ext/standard/file.h" /* for php_file_le_uploads() */ > #include "php_variables.h" > 119a123,188 > SAPI_API void sapi_handle_put(SLS_D) { > char *fn; // temporary uploded file name > FILE *fp; // temporary file pointer > long length; // file length > > int to_read_bytes, read_bytes = 0; > int write_bytes = 0; > char* buf=0; > > //php_log_err("php: sapi_handle_put()"); > > ELS_FETCH(); // i don't know what it do, and if it is needed. It was used in > PLS_FETCH(); // rfc1867.c when handling file upload > > length = SG(request_info).content_length; > fn = tempnam(PG(upload_tmp_dir), "php"); > > if (length > PG(upload_max_filesize)) { > php_log_err("php: PUT > upload_max_filesize"); > php_error(E_WARNING, "Max file size of %ld bytes exceeded - PUT file not saved", > PG(upload_max_filesize)); > SG(sapi_headers).http_response_code = 413; // Request Entity Too Large > fn = "none"; > } else { > fp = fopen(fn,"wb"); > if (!fp) { > php_log_err("php: can't open temp file"); > php_error(E_WARNING, "File PUT Error - Unable to open temporary file [%s]", > fn); > SG(sapi_headers).http_response_code = 500; // Internal Server Error > return; > } > > buf = emalloc(length > SAPI_POST_BLOCK_SIZE ? SAPI_POST_BLOCK_SIZE : length); > to_read_bytes = length; > while (to_read_bytes > 0) { > read_bytes = sapi_module.read_post(buf, > (to_read_bytes > SAPI_POST_BLOCK_SIZE ? > SAPI_POST_BLOCK_SIZE : to_read_bytes) SLS_CC > ); > if (read_bytes<=0) { > break; > } > to_read_bytes -= read_bytes; > write_bytes += fwrite(buf,1,read_bytes,fp); > } > if (buf) { > efree(buf); > } > fclose(fp); > zend_list_insert(fn,php_file_le_uploads()); > /* Tell PHP about the file so the destructor can unlink it later */ > if (write_bytes != length) > { > php_log_err("php: hasn't write all the bytes"); > php_error(E_WARNING, "Only %d bytes were written, expected to write %ld", > write_bytes, length); > SG(sapi_headers).http_response_code = 500; // Internal Server Error > } > } > php_register_variable("PHP_PUT_FILENAME",fn,NULL ELS_CC PLS_CC); > //php_log_err("php: /sapi_handle_put"); > } > > >