X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http.c;h=6efc142e9745cf43fd8ff9be481736e480d1626c;hp=74e2968ec7839e831796611a4a0f807a6e21e0ba;hb=96d32e2bd4a5d2b0741addf6f59b46d7d8749937;hpb=b587077029cfd30b2daf4f4d519f69c37fae1841 diff --git a/http.c b/http.c index 74e2968..6efc142 100644 --- a/http.c +++ b/http.c @@ -31,6 +31,10 @@ #include "php_http.h" #include "php_http_api.h" +#ifdef ZEND_ENGINE_2 +#include "ext/standard/php_http.h" +#endif + #ifdef HTTP_HAVE_CURL #ifdef PHP_WIN32 @@ -67,6 +71,7 @@ function_entry http_functions[] = { PHP_FE(http_send_stream, NULL) PHP_FE(http_chunked_decode, NULL) PHP_FE(http_split_response, NULL) + PHP_FE(http_parse_headers, NULL) #ifdef HTTP_HAVE_CURL PHP_FE(http_get, NULL) PHP_FE(http_head, NULL) @@ -75,6 +80,9 @@ function_entry http_functions[] = { #endif PHP_FE(http_auth_basic, NULL) PHP_FE(http_auth_basic_cb, NULL) +#ifndef ZEND_ENGINE_2 + PHP_FE(http_build_query, NULL) +#endif {NULL, NULL, NULL} }; /* }}} */ @@ -670,7 +678,10 @@ PHP_FUNCTION(http_split_response) MAKE_STD_ZVAL(zheaders); array_init(zheaders); - http_split_response(zresponse, zheaders, zbody); + if (SUCCESS != http_split_response(zresponse, zheaders, zbody)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not parse HTTP response"); + RETURN_FALSE; + } array_init(return_value); add_index_zval(return_value, 0, zheaders); @@ -678,6 +689,29 @@ PHP_FUNCTION(http_split_response) } /* }}} */ +/* {{{ proto array http_parse_headers(string header) */ +PHP_FUNCTION(http_parse_headers) +{ + char *header, *rnrn; + int header_len; + + if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &header, &header_len)) { + RETURN_FALSE; + } + + array_init(return_value); + + if (rnrn = strstr(header, HTTP_CRLF HTTP_CRLF)) { + header_len = rnrn - header + 2; + } + if (SUCCESS != http_parse_headers(header, header_len, return_value)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not parse HTTP header"); + zval_dtor(return_value); + RETURN_FALSE; + } +} +/* }}}*/ + /* {{{ HAVE_CURL */ #ifdef HTTP_HAVE_CURL