attempt to fix #92
[m6w6/ext-http] / src / php_http_message_body.c
index 518dbc9b71ef34b57362a63463a2f100c7d5e3b7..f0068b817a0fdf6714beac88d83b6f59f7250dae 100644 (file)
@@ -214,7 +214,7 @@ size_t php_http_message_body_append(php_http_message_body_t *body, const char *b
        written = php_stream_write(s, buf, len);
 
        if (written != len) {
-               php_error_docref(NULL, E_WARNING, "Failed to append %zu bytes to body; wrote %zu", len, written);
+               php_error_docref(NULL, E_WARNING, "Failed to append %zu bytes to body; wrote %zu", len, written == (size_t) -1 ? 0 : written);
        }
 
        return len;
@@ -330,7 +330,7 @@ static inline char *format_key(php_http_arrkey_t *key, const char *prefix) {
        } else if (key->key) {
                new_key = estrdup(key->key->val);
        } else {
-               new_key = estrdup("");
+               spprintf(&new_key, 0, "%lu", key->h);
        }
 
        return new_key;
@@ -907,7 +907,7 @@ PHP_METHOD(HttpMessageBody, stat)
 }
 
 static zend_function_entry php_http_message_body_methods[] = {
-       PHP_ME(HttpMessageBody, __construct,  ai_HttpMessageBody___construct,  ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
+       PHP_ME(HttpMessageBody, __construct,  ai_HttpMessageBody___construct,  ZEND_ACC_PUBLIC)
        PHP_ME(HttpMessageBody, __toString,   ai_HttpMessageBody___toString,   ZEND_ACC_PUBLIC)
        PHP_MALIAS(HttpMessageBody, toString, __toString, ai_HttpMessageBody___toString, ZEND_ACC_PUBLIC)
        PHP_MALIAS(HttpMessageBody, serialize, __toString, ai_HttpMessageBody___toString, ZEND_ACC_PUBLIC)