- http_request_defaults() already takes care of resetting curl options so check strin...
[m6w6/ext-http] / http_api.c
index 07cb9f4dbced71aadc65962c5735266befb3c248..edd80aeec36cc3087b3facd79114da9cc7af7cd0 100644 (file)
@@ -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 <mike@php.net>            |
+    | Copyright (c) 2004-2006, Michael Wallner <mike@php.net>            |
     +--------------------------------------------------------------------+
 */
 
@@ -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;
 }
 /* }}} */