From 7610da74c78e8de1ba61bc22cef6c445472ea424 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 7 Mar 2005 07:12:24 +0000 Subject: [PATCH] * run tests on linux - flushing changes --- http_api.c | 14 +++++++++----- tests/050_split_response.phpt | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/http_api.c b/http_api.c index edeb00b..4838783 100644 --- a/http_api.c +++ b/http_api.c @@ -23,6 +23,7 @@ #endif #include +#include #include "php.h" #include "php_version.h" @@ -918,7 +919,7 @@ PHP_HTTP_API char *_http_absolute_uri_ex( } else if (purl->scheme) { furl.scheme = purl->scheme; #ifdef ZEND_ENGINE_2 - } else if (port && (se = getservbyport(htons(port), "tcp"))) { + } else if (port && (se = getservbyport(port, "tcp"))) { furl.scheme = (scheme = estrdup(se->s_name)); #endif } else { @@ -932,7 +933,7 @@ PHP_HTTP_API char *_http_absolute_uri_ex( } else if (strncmp(furl.scheme, "http", 4)) { #ifdef ZEND_ENGINE_2 if (se = getservbyname(furl.scheme, "tcp")) { - furl.port = ntohs(se->s_port); + furl.port = se->s_port; } else #endif furl.port = 80; @@ -982,14 +983,17 @@ PHP_HTTP_API char *_http_absolute_uri_ex( HTTP_URI_STRLCATL(URL, full_len, furl.host); - if ( (strcmp(furl.scheme, "http") && (furl.port != 80)) || - (strcmp(furl.scheme, "https") && (furl.port != 443))) { + if ( (!strcmp(furl.scheme, "http") && (furl.port != 80)) || + (!strcmp(furl.scheme, "https") && (furl.port != 443))) { char port_string[8] = {0}; snprintf(port_string, 7, ":%u", furl.port); HTTP_URI_STRLCATL(URL, full_len, port_string); } if (furl.path) { + if (furl.path[0] != '/') { + HTTP_URI_STRLCATS(URL, full_len, "/"); + } HTTP_URI_STRLCATL(URL, full_len, furl.path); } else { HTTP_URI_STRLCATS(URL, full_len, "/"); @@ -1456,7 +1460,7 @@ PHP_HTTP_API STATUS _http_chunked_decode(const char *encoded, PHP_HTTP_API STATUS _http_split_response(zval *response, zval *headers, zval *body TSRMLS_DC) { char *b = NULL; - long l = 0; + size_t l = 0; STATUS status = http_split_response_ex(Z_STRVAL_P(response), Z_STRLEN_P(response), Z_ARRVAL_P(headers), &b, &l); ZVAL_STRINGL(body, b, l, 0); return status; diff --git a/tests/050_split_response.phpt b/tests/050_split_response.phpt index 3a562fd..cf99af3 100644 --- a/tests/050_split_response.phpt +++ b/tests/050_split_response.phpt @@ -7,7 +7,7 @@ strncasecmp(PHP_SAPI, 'CLI', 3) or die('cannot run tests with CLI'); ?> --FILE-- --EXPECTF-- Content-type: text/html -- 2.30.2