From f33ddcab9445fdc1a764547a07de1182a010eb1c Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Sun, 6 Mar 2005 11:30:35 +0000 Subject: [PATCH] * excluding getservby*() in PHP4 (??) --- http_api.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/http_api.c b/http_api.c index 0e4e604..aee6785 100644 --- a/http_api.c +++ b/http_api.c @@ -886,8 +886,10 @@ PHP_HTTP_API char *_http_absolute_uri_ex( const char *host, size_t host_len, unsigned port TSRMLS_DC) { - php_url *purl, furl = {NULL}; +#ifdef ZEND_ENGINE_2 struct servent *se; +#endif + php_url *purl, furl = {NULL}; size_t full_len = 0; zval *zhost = NULL; char *scheme = NULL, *URL = ecalloc(1, HTTP_URI_MAXLEN + 1); @@ -915,8 +917,10 @@ PHP_HTTP_API char *_http_absolute_uri_ex( furl.scheme = scheme = estrdup(proto); } else if (purl->scheme) { furl.scheme = purl->scheme; +#ifdef ZEND_ENGINE_2 } else if (port && (se = getservbyport(htons(port), "tcp"))) { furl.scheme = (scheme = estrdup(se->s_name)); +#endif } else { furl.scheme = "http"; } @@ -925,10 +929,15 @@ PHP_HTTP_API char *_http_absolute_uri_ex( furl.port = port; } else if (purl->port) { furl.port = purl->port; - } else if (strncmp(furl.scheme, "http", 4) && (se = getservbyname(furl.scheme, "tcp"))) { - furl.port = ntohs(se->s_port); + } else if (strncmp(furl.scheme, "http", 4)) { +#ifdef ZEND_ENGINE_2 + if (se = getservbyname(furl.scheme, "tcp")) { + furl.port = ntohs(se->s_port); + } else +#endif + furl.port = 80; } else { - furl.port = furl.scheme[5] ? 443 : 80; + furl.port = (furl.scheme[5] == 's') ? 443 : 80; } if (host) { @@ -1469,7 +1478,7 @@ PHP_HTTP_API STATUS _http_split_response_ex(char *response, /* }}} */ /* {{{ STATUS http_parse_headers(char *, long, zval *) */ -PHP_HTTP_API STATUS _http_parse_headers_ex(char *header, int header_len, +PHP_HTTP_API STATUS _http_parse_headers_ex(char *header, int header_len, HashTable *headers, zend_bool prettify TSRMLS_DC) { char *colon = NULL, *line = NULL, *begin = header; @@ -1549,17 +1558,17 @@ PHP_HTTP_API void _http_get_request_headers_ex(HashTable *headers, zend_bool pre char *key = NULL; long idx = 0; zval array; - + Z_ARRVAL(array) = headers; FOREACH_HASH_KEY(HTTP_SERVER_VARS, key, idx) { if (key && !strncmp(key, "HTTP_", 5)) { zval **header; - + if (prettify) { key = pretty_key(key + 5, strlen(key) - 5, 1, 1); } - + zend_hash_get_current_data(HTTP_SERVER_VARS, (void **) &header); add_assoc_stringl(&array, key, Z_STRVAL_PP(header), Z_STRLEN_PP(header), 1); key = NULL; -- 2.30.2