- zval *zhost;
-
- if ((((zhost = http_get_server_var("HTTP_HOST", 1)) ||
- (zhost = http_get_server_var("SERVER_NAME", 1)))) && Z_STRLEN_P(zhost)) {
- url->host = estrndup(Z_STRVAL_P(zhost), Z_STRLEN_P(zhost));
+ if (flags & HTTP_URL_FROM_ENV) {
+ zval *zhost;
+
+ if ((((zhost = http_get_server_var("HTTP_HOST", 1)) ||
+ (zhost = http_get_server_var("SERVER_NAME", 1)))) && Z_STRLEN_P(zhost)) {
+ url->host = estrndup(Z_STRVAL_P(zhost), Z_STRLEN_P(zhost));
+ } else {
+ url->host = localhostname();
+ }