X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_message_api.c;h=8d062b1bac600e3bb6e48a385a0f30372addd103;hp=e4ded1e799ca0204817826e47401436508d52e83;hb=3177ba2e5ef642f38c01568afcaa547df65f3e74;hpb=3f8d6ea256f520d439cebc37c46bb93c30b2660e diff --git a/http_message_api.c b/http_message_api.c index e4ded1e..8d062b1 100644 --- a/http_message_api.c +++ b/http_message_api.c @@ -31,6 +31,8 @@ #include "phpstr/phpstr.h" +ZEND_EXTERN_MODULE_GLOBALS(http); + #define http_message_headers_cb _http_message_headers_cb static void _http_message_headers_cb(const char *http_line, HashTable **headers, void **message TSRMLS_DC) { @@ -327,10 +329,17 @@ PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC) FOREACH_HASH_KEYVAL(&message->hdrs, key, idx, val) { if (key) { - char *header; - spprintf(&header, 0, "%s: %s", key, Z_STRVAL_PP(val)); - http_send_header(header); - efree(header); + if (Z_TYPE_PP(val) == IS_ARRAY) { + zend_bool first = 1; + zval **data; + + FOREACH_VAL(*val, data) { + http_send_header_ex(key, strlen(key), Z_STRVAL_PP(data), Z_STRLEN_PP(data), first); + first = 0; + } + } else { + http_send_header_ex(key, strlen(key), Z_STRVAL_PP(val), Z_STRLEN_PP(val), 1); + } key = NULL; } } @@ -382,21 +391,21 @@ PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC) if (!strcasecmp("HEAD", message->info.request.method)) { rs = http_head(uri, Z_ARRVAL(options), NULL, NULL); } else { - http_error_ex(E_WARNING, HTTP_E_MSG, + http_error_ex(HE_WARNING, HTTP_E_REQUEST_METHOD, "Cannot send HttpMessage. Request method %s not supported", message->info.request.method); } efree(uri); #else - http_error(E_WARNING, HTTP_E_MSG, "HTTP requests not supported - ext/http was not linked against libcurl."); + http_error(HE_WARNING, HTTP_E_RUNTIME, "HTTP requests not supported - ext/http was not linked against libcurl."); #endif } break; case HTTP_MSG_NONE: default: - http_error(E_WARNING, HTTP_E_MSG, "HttpMessage is neither of type HTTP_MSG_REQUEST nor HTTP_MSG_RESPONSE"); + http_error(HE_WARNING, HTTP_E_MESSAGE_TYPE, "HttpMessage is neither of type HTTP_MSG_REQUEST nor HTTP_MSG_RESPONSE"); break; } @@ -456,3 +465,4 @@ PHP_HTTP_API void _http_message_free(http_message *message) * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */ +