Removed port and scheme guessing of http\Url for portability
authorMichael Wallner <mike@php.net>
Wed, 13 Aug 2014 10:29:44 +0000 (12:29 +0200)
committerMichael Wallner <mike@php.net>
Wed, 13 Aug 2014 10:29:44 +0000 (12:29 +0200)
config.w32
config9.m4
package.xml
php_http_api.h
php_http_url.c

index 497fb650175edaa9a36b0bc0271414e3eb092fe3..b84101f79af9a389546b4731db267a7791a37e5e 100644 (file)
@@ -61,8 +61,6 @@ if (PHP_HTTP != "no") {
        AC_DEFINE("HTTP_SHARED_DEPS", 1, "Depend on shared extensions");\r
        \r
        AC_DEFINE("HAVE_GETHOSTNAME", 1);\r
-       AC_DEFINE("HAVE_GETSERVBYPORT", 1);\r
-       AC_DEFINE("HAVE_GETSERVBYNAME", 1);\r
        \r
        if (PHP_DEBUG != "no") {\r
                ADD_FLAG("CFLAGS_HTTP", "/W3");\r
index ba1b93511b551885c801bcead58a0503532346d1..17e993327c062b27adf2fbd84b8ed56c6e30975b 100644 (file)
@@ -96,13 +96,10 @@ if test "$PHP_HTTP" != "no"; then
 dnl ----
 dnl STDC
 dnl ----
+       dnl getdomainname() is declared in netdb.h on some platforms: AIX, OSF
        AC_CHECK_HEADERS([netdb.h unistd.h])
        PHP_CHECK_FUNC(gethostname, nsl)
        PHP_CHECK_FUNC(getdomainname, nsl)
-       PHP_CHECK_FUNC(getservbyport, nsl)
-       PHP_CHECK_FUNC(getservbyport_r, nsl)
-       PHP_CHECK_FUNC(getservbyname, nsl)
-       PHP_CHECK_FUNC(getservbyname_r, nsl)
 
 dnl ----
 dnl ZLIB
index bd7b57913058ff7c6be53d0bac2440634d953978..4354350832717646ec76176629788f66d2b5e132 100644 (file)
@@ -49,6 +49,8 @@ v2: http://dev.iworks.at/ext-http/lcov/ext/http/
  <license>BSD, revised</license>
  <notes><![CDATA[
 Changes from RC2:
+* Fixed PHP-5.3 compatibility
+- Removed port and scheme guessing of http\Url for portability
 ]]></notes>
  <contents>
   <dir name="/">
index 9e0dc6ca69bc39fa7eb80263fbf78a24f56a378a..091fd6590f8243fd0fe6d70c800f3a986c9c7b1f 100644 (file)
@@ -58,17 +58,14 @@ typedef int STATUS;
 
 #ifdef PHP_WIN32
 #      define CURL_STATICLIB
-#      define PHP_HTTP_HAVE_NETDB
 #      include <winsock2.h>
-#elif defined(HAVE_NETDB_H)
-#      define PHP_HTTP_HAVE_NETDB
-#      include <netdb.h>
+#else
+#      ifdef HAVE_NETDB_H
+#              include <netdb.h>
+#      endif
 #      ifdef HAVE_UNISTD_H
 #              include <unistd.h>
 #      endif
-#      ifdef HAVE_ERRNO_H
-#              include <errno.h>
-#      endif
 #endif
 
 #include <ctype.h>
index c4eb90b5d34d395ccb2acd9dacf42f235b4af0f2..7c8077b6a31995208a8a16da0ed6789d68bd2878 100644 (file)
@@ -42,94 +42,6 @@ static inline char *localhostname(void)
        return estrndup("localhost", lenof("localhost"));
 }
 
-static inline unsigned port(const char *scheme)
-{
-       unsigned port = 80;
-
-#if defined(ZTS) && defined(HAVE_GETSERVBYPORT_R)
-       int rc;
-       size_t len = 0xff;
-       char *buf = NULL;
-       struct servent *se_res = NULL, se_buf = {0};
-
-       do {
-               buf = erealloc(buf, len);
-               rc = getservbyname_r(scheme, "tcp", &se_buf, buf, len, &se_res);
-               len *= 2;
-       } while (rc == ERANGE && len <= 0xfff);
-
-       if (!rc) {
-               port = ntohs(se_res->s_port);
-       }
-
-       efree(buf);
-#elif !defined(ZTS) && defined(HAVE_GETSERVBYPORT)
-       struct servent *se;
-
-       if ((se = getservbyname(scheme, "tcp")) && se->s_port) {
-               port = ntohs(se->s_port);
-       }
-#endif
-
-       return port;
-}
-static inline char *scheme(unsigned port)
-{
-       char *scheme;
-#if defined(ZTS) && defined(HAVE_GETSERVBYPORT_R)
-       int rc;
-       size_t len = 0xff;
-       char *buf = NULL;
-       struct servent *se_res = NULL, se_buf = {0};
-#elif !defined(ZTS) && defined(HAVE_GETSERVBYPORT)
-       struct servent *se;
-#endif
-
-       switch (port) {
-       case 443:
-               scheme = estrndup("https", lenof("https"));
-               break;
-
-#if defined(ZTS) && !defined(HAVE_GETSERVBYPORT_R)
-       default:
-#elif !defined(ZTS) && !defined(HAVE_GETSERVBYPORT)
-       default:
-#endif
-       case 80:
-       case 0:
-               scheme = estrndup("http", lenof("http"));
-               break;
-
-#if defined(ZTS) && defined(HAVE_GETSERVBYPORT_R)
-       default:
-               do {
-                       buf = erealloc(buf, len);
-                       rc = getservbyport_r(htons(port), "tcp", &se_buf, buf, len, &se_res);
-                       len *= 2;
-               } while (rc == ERANGE && len <= 0xfff);
-
-               if (!rc && se_res) {
-                       scheme = estrdup(se_res->s_name);
-               } else {
-                       scheme = estrndup("http", lenof("http"));
-               }
-
-               efree(buf);
-               break;
-
-#elif !defined(ZTS) && defined(HAVE_GETSERVBYPORT)
-       default:
-               if ((se = getservbyport(htons(port), "tcp")) && se->s_name) {
-                       scheme = estrdup(se->s_name);
-               } else {
-                       scheme = estrndup("http", lenof("http"));
-               }
-               break;
-#endif
-       }
-       return scheme;
-}
-
 static php_url *php_http_url_from_env(php_url *url TSRMLS_DC)
 {
        zval *https, *zhost, *zport;
@@ -150,7 +62,7 @@ static php_url *php_http_url_from_env(php_url *url TSRMLS_DC)
        if (https && !strcasecmp(Z_STRVAL_P(https), "ON")) {
                url->scheme = estrndup("https", lenof("https"));
        } else {
-               url->scheme = scheme(url->port);
+               url->scheme = estrndup("http", lenof("http"));
        }
 
        /* host */
@@ -339,7 +251,6 @@ void php_http_url(int flags, const php_url *old_url, const php_url *new_url, php
        if (url->port) {
                if (    ((url->port == 80) && !strcmp(url->scheme, "http"))
                        ||      ((url->port ==443) && !strcmp(url->scheme, "https"))
-                       ||      ( url->port == port(url->scheme))
                ) {
                        url->port = 0;
                }