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);
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";
}
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) {
/* }}} */
/* {{{ 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;
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;