Skip to content

Commit

Permalink
Update version for Swoole 4.4.25 (#4137)
Browse files Browse the repository at this point in the history
* Fix httpclient proxy with host and port (#4124)

* Fix proxy with host and port

* Change strstr to memchr
# Conflicts:
#	swoole_http_client_coro.cc

* Update version for Swoole 4.4.25
  • Loading branch information
Yurunsoft authored Apr 8, 2021
1 parent ba5d66a commit ee7affd
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PROJECT(libswoole)

ENABLE_LANGUAGE(ASM)
SET(SWOOLE_VERSION 4.4.24)
SET(SWOOLE_VERSION 4.4.25)
SET(SWOOLE_CLFLAGS pthread rt dl ssl crypt crypto)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
Expand Down
6 changes: 3 additions & 3 deletions include/swoole.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ int clock_gettime(clock_id_t which_clock, struct timespec *t);

#define SWOOLE_MAJOR_VERSION 4
#define SWOOLE_MINOR_VERSION 4
#define SWOOLE_RELEASE_VERSION 24
#define SWOOLE_RELEASE_VERSION 25
#define SWOOLE_EXTRA_VERSION ""
#define SWOOLE_VERSION "4.4.24"
#define SWOOLE_VERSION_ID 40424
#define SWOOLE_VERSION "4.4.25"
#define SWOOLE_VERSION_ID 40425
#define SWOOLE_BUG_REPORT \
"A bug occurred in Swoole-v" SWOOLE_VERSION ", please report it.\n"\
"The Swoole developers probably don't know about it,\n"\
Expand Down
9 changes: 5 additions & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
<email>[email protected]</email>
<active>yes</active>
</developer>
<date>2021-03-09</date>
<time>20:00:00</time>
<date>2021-04-08</date>
<time>10:00:00</time>
<version>
<release>4.4.24</release>
<release>4.4.25</release>
<api>4.0</api>
</version>
<stability>
Expand All @@ -56,7 +56,7 @@
<notes>
Fixed
---
* Fix crash when http2 client connects concurrently
* Fix httpclient proxy with host and port
</notes>
<contents>
<dir name="/">
Expand Down Expand Up @@ -1052,6 +1052,7 @@
<file role="test" name="tests/swoole_http_client_coro/host.phpt" />
<file role="test" name="tests/swoole_http_client_coro/http_proxy.phpt" />
<file role="test" name="tests/swoole_http_client_coro/http_proxy_443.phpt" />
<file role="test" name="tests/swoole_http_client_coro/http_proxy_with_host_port.phpt" />
<file role="test" name="tests/swoole_http_client_coro/http_upload_big.phpt" />
<file role="test" name="tests/swoole_http_client_coro/https.phpt" />
<file role="test" name="tests/swoole_http_client_coro/https_upload_big.phpt" />
Expand Down
6 changes: 5 additions & 1 deletion swoole_http_client_coro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,11 @@ bool http_client::send()
}
size_t proxy_uri_len = path.length() + _host_len + strlen(pre) + 10;
char *proxy_uri = (char*) emalloc(proxy_uri_len);
proxy_uri_len = sw_snprintf(proxy_uri, proxy_uri_len, "%s%s:%u%s", pre, _host, port, path.c_str());
if (nullptr == memchr(_host, ':', _host_len)) {
proxy_uri_len = sw_snprintf(proxy_uri, proxy_uri_len, "%s%s:%u%s", pre, _host, port, path.c_str());
} else {
proxy_uri_len = sw_snprintf(proxy_uri, proxy_uri_len, "%s%s%s", pre, _host, path.c_str());
}
swString_append_ptr(buffer, proxy_uri, proxy_uri_len);
efree(proxy_uri);
}
Expand Down
50 changes: 50 additions & 0 deletions tests/swoole_http_client_coro/http_proxy_with_host_port.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
--TEST--
swoole_http_client_coro: http client with http_proxy and host and port
--SKIPIF--
<?php
require __DIR__.'/../include/skipif.inc';
?>
--FILE--
<?php
require __DIR__.'/../include/bootstrap.php';

$pm = new SwooleTest\ProcessManager;
$pm->parentFunc = function () use ($pm) {
Co\run(function () use ($pm) {
$cli = new Swoole\Coroutine\Http\Client('127.0.0.1', 1234);
$cli->set([
'timeout' => 30,
'http_proxy_host' => '127.0.0.1',
'http_proxy_port' => $pm->getFreePort(),
]);
$cli->setHeaders([
'Host' => '127.0.0.1:1234',
]);
$cli->get('/');
$pm->kill();
});
};

$pm->childFunc = function () use ($pm) {
$server = new Swoole\Server('0.0.0.0', $pm->getFreePort(), SWOOLE_BASE);
$server->set([
'log_file' => '/dev/null',
'open_eof_check' => true,
'package_eof' => "\r\n\r\n",
]);
$server->on('Receive', function ($server, $fd, $reactor_id, $data) {
echo $data;
$server->close($fd);
});
$server->start();
};

$pm->childFirst();
$pm->run();

?>
--EXPECT--
GET http://127.0.0.1:1234/ HTTP/1.1
Host: 127.0.0.1:1234
Connection: keep-alive
Accept-Encoding: gzip, deflate

0 comments on commit ee7affd

Please sign in to comment.