X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=http_url_api.c;h=db4ca96fd7abe76a47fdca84c9473eddcaa44845;hb=389e280e0bba312ff5ca9981801cc842dad26ec2;hp=07204608b1af731e721e820746e01e9c4abd5cb5;hpb=213951e5268262c6dbea4b05b852510132f3367b;p=m6w6%2Fext-http diff --git a/http_url_api.c b/http_url_api.c index 0720460..db4ca96 100644 --- a/http_url_api.c +++ b/http_url_api.c @@ -6,20 +6,16 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2005, Michael Wallner | + | Copyright (c) 2004-2006, Michael Wallner | +--------------------------------------------------------------------+ */ /* $Id$ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - +#define HTTP_WANT_SAPI #define HTTP_WANT_NETDB #include "php_http.h" -#include "SAPI.h" #include "zend_ini.h" #include "php_output.h" #include "ext/standard/php_string.h" @@ -27,8 +23,6 @@ #include "php_http_api.h" #include "php_http_url_api.h" -ZEND_EXTERN_MODULE_GLOBALS(http); - PHP_HTTP_API char *_http_absolute_url(const char *url TSRMLS_DC) { char *abs = estrdup(url); @@ -39,6 +33,8 @@ PHP_HTTP_API char *_http_absolute_url(const char *url TSRMLS_DC) if (purl) { http_build_url(purl, NULL, NULL, &abs, NULL); php_url_free(purl); + } else { + http_error_ex(HE_WARNING, HTTP_E_URL, "Could not parse URL (%s)", url); } return abs; @@ -47,7 +43,7 @@ PHP_HTTP_API char *_http_absolute_url(const char *url TSRMLS_DC) /* {{{ void http_build_url(const php_url *, const php_url *, php_url **, char **, size_t *) */ PHP_HTTP_API void _http_build_url(const php_url *old_url, const php_url *new_url, php_url **url_ptr, char **url_str, size_t *url_len TSRMLS_DC) { -#if defined(PHP_WIN32) || defined(HAVE_NETDB_H) +#ifdef HTTP_HAVE_NETDB struct servent *se; #endif php_url *url = emalloc(sizeof(php_url)); @@ -70,14 +66,14 @@ PHP_HTTP_API void _http_build_url(const php_url *old_url, const php_url *new_url url->scheme = estrndup("https", lenof("https")); break; -#if !defined(PHP_WIN32) && !defined(HAVE_NETDB_H) +#ifndef HTTP_HAVE_NETDB default: #endif case 80: url->scheme = estrndup("http", lenof("http")); break; -#if defined(PHP_WIN32) || defined(HAVE_NETDB_H) +#ifdef HTTP_HAVE_NETDB default: if ((se = getservbyport(htons(url->port), "tcp")) && se->s_name) { url->scheme = estrdup(se->s_name); @@ -139,7 +135,7 @@ PHP_HTTP_API void _http_build_url(const php_url *old_url, const php_url *new_url if (url->port) { if ( ((url->port == 80) && !strcmp(url->scheme, "http")) || ((url->port ==443) && !strcmp(url->scheme, "https")) -#if defined(PHP_WIN32) || defined(HAVE_NETDB_H) +#ifdef HTTP_HAVE_NETDB || ((se = getservbyname(url->scheme, "tcp")) && se->s_port && (url->port == ntohs(se->s_port))) #endif @@ -299,13 +295,7 @@ PHP_HTTP_API STATUS _http_urlencode_hash_recursive(HashTable *ht, phpstr *str, c return FAILURE; } } else { - zval *val; - - ALLOC_ZVAL(val); - *val = **data; - INIT_PZVAL(val); - zval_copy_ctor(val); - convert_to_string(val); + zval *val = zval_copy(IS_STRING, *data); if (PHPSTR_LEN(str)) { phpstr_append(str, arg_sep, arg_sep_len); @@ -322,7 +312,7 @@ PHP_HTTP_API STATUS _http_urlencode_hash_recursive(HashTable *ht, phpstr *str, c efree(encoded_val); } - zval_ptr_dtor(&val); + zval_free(&val); } phpstr_dtor(&new_prefix); }