X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_api.c;h=edd80aeec36cc3087b3facd79114da9cc7af7cd0;hp=07cb9f4dbced71aadc65962c5735266befb3c248;hb=fa1a275e2b5e1b9dfb5bcbf97b51ef2b568e433c;hpb=7b88d9022c90eb12e5fe195af8644935141c9d68 diff --git a/http_api.c b/http_api.c index 07cb9f4..edd80ae 100644 --- a/http_api.c +++ b/http_api.c @@ -6,7 +6,7 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2005, Michael Wallner | + | Copyright (c) 2004-2006, Michael Wallner | +--------------------------------------------------------------------+ */ @@ -206,9 +206,7 @@ void _http_log_ex(char *file, const char *ident, const char *message TSRMLS_DC) { time_t now; struct tm nowtm; - char datetime[128]; - - HTTP_CHECK_OPEN_BASEDIR(file, return); + char datetime[20] = {0}; time(&now); strftime(datetime, sizeof(datetime), "%Y-%m-%d %H:%M:%S", php_localtime_r(&now, &nowtm)); @@ -319,6 +317,33 @@ PHP_HTTP_API STATUS _http_get_request_body_ex(char **body, size_t *length, zend_ *body = (char *) (dup ? estrndup(SG(request_info).raw_post_data, *length) : SG(request_info).raw_post_data); return SUCCESS; } + + /* PHP only reads POST */ + if (sapi_module.read_post) { + char buf[4096]; + int len; + + while (0 < (len = sapi_module.read_post(buf, sizeof(buf) TSRMLS_CC))) { + *body = erealloc(*body, *length + len + 1); + memcpy(*body + *length, buf, len); + *length += len; + (*body)[*length] = '\0'; + } + + /* check for error */ + if (len >= 0) { + /* connect to sapi module so it'll be freed */ + if (!dup) { + SG(request_info).raw_post_data = *body; + SG(request_info).raw_post_data_length = *length; + } + return SUCCESS; + } else { + STR_FREE(*body); + *length = 0; + } + } + return FAILURE; } /* }}} */