Skip to content

Commit ee7affd

Browse files
authored
Update version for Swoole 4.4.25 (swoole#4137)
* Fix httpclient proxy with host and port (swoole#4124) * Fix proxy with host and port * Change strstr to memchr # Conflicts: # swoole_http_client_coro.cc * Update version for Swoole 4.4.25
1 parent ba5d66a commit ee7affd

File tree

5 files changed

+64
-9
lines changed

5 files changed

+64
-9
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PROJECT(libswoole)
22

33
ENABLE_LANGUAGE(ASM)
4-
SET(SWOOLE_VERSION 4.4.24)
4+
SET(SWOOLE_VERSION 4.4.25)
55
SET(SWOOLE_CLFLAGS pthread rt dl ssl crypt crypto)
66
set(CMAKE_CXX_STANDARD 11)
77
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")

include/swoole.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ int clock_gettime(clock_id_t which_clock, struct timespec *t);
102102

103103
#define SWOOLE_MAJOR_VERSION 4
104104
#define SWOOLE_MINOR_VERSION 4
105-
#define SWOOLE_RELEASE_VERSION 24
105+
#define SWOOLE_RELEASE_VERSION 25
106106
#define SWOOLE_EXTRA_VERSION ""
107-
#define SWOOLE_VERSION "4.4.24"
108-
#define SWOOLE_VERSION_ID 40424
107+
#define SWOOLE_VERSION "4.4.25"
108+
#define SWOOLE_VERSION_ID 40425
109109
#define SWOOLE_BUG_REPORT \
110110
"A bug occurred in Swoole-v" SWOOLE_VERSION ", please report it.\n"\
111111
"The Swoole developers probably don't know about it,\n"\

package.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
<email>shenzhe163@gmail.com</email>
4343
<active>yes</active>
4444
</developer>
45-
<date>2021-03-09</date>
46-
<time>20:00:00</time>
45+
<date>2021-04-08</date>
46+
<time>10:00:00</time>
4747
<version>
48-
<release>4.4.24</release>
48+
<release>4.4.25</release>
4949
<api>4.0</api>
5050
</version>
5151
<stability>
@@ -56,7 +56,7 @@
5656
<notes>
5757
Fixed
5858
---
59-
* Fix crash when http2 client connects concurrently
59+
* Fix httpclient proxy with host and port
6060
</notes>
6161
<contents>
6262
<dir name="/">
@@ -1052,6 +1052,7 @@
10521052
<file role="test" name="tests/swoole_http_client_coro/host.phpt" />
10531053
<file role="test" name="tests/swoole_http_client_coro/http_proxy.phpt" />
10541054
<file role="test" name="tests/swoole_http_client_coro/http_proxy_443.phpt" />
1055+
<file role="test" name="tests/swoole_http_client_coro/http_proxy_with_host_port.phpt" />
10551056
<file role="test" name="tests/swoole_http_client_coro/http_upload_big.phpt" />
10561057
<file role="test" name="tests/swoole_http_client_coro/https.phpt" />
10571058
<file role="test" name="tests/swoole_http_client_coro/https_upload_big.phpt" />

swoole_http_client_coro.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,11 @@ bool http_client::send()
961961
}
962962
size_t proxy_uri_len = path.length() + _host_len + strlen(pre) + 10;
963963
char *proxy_uri = (char*) emalloc(proxy_uri_len);
964-
proxy_uri_len = sw_snprintf(proxy_uri, proxy_uri_len, "%s%s:%u%s", pre, _host, port, path.c_str());
964+
if (nullptr == memchr(_host, ':', _host_len)) {
965+
proxy_uri_len = sw_snprintf(proxy_uri, proxy_uri_len, "%s%s:%u%s", pre, _host, port, path.c_str());
966+
} else {
967+
proxy_uri_len = sw_snprintf(proxy_uri, proxy_uri_len, "%s%s%s", pre, _host, path.c_str());
968+
}
965969
swString_append_ptr(buffer, proxy_uri, proxy_uri_len);
966970
efree(proxy_uri);
967971
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
--TEST--
2+
swoole_http_client_coro: http client with http_proxy and host and port
3+
--SKIPIF--
4+
<?php
5+
require __DIR__.'/../include/skipif.inc';
6+
?>
7+
--FILE--
8+
<?php
9+
require __DIR__.'/../include/bootstrap.php';
10+
11+
$pm = new SwooleTest\ProcessManager;
12+
$pm->parentFunc = function () use ($pm) {
13+
Co\run(function () use ($pm) {
14+
$cli = new Swoole\Coroutine\Http\Client('127.0.0.1', 1234);
15+
$cli->set([
16+
'timeout' => 30,
17+
'http_proxy_host' => '127.0.0.1',
18+
'http_proxy_port' => $pm->getFreePort(),
19+
]);
20+
$cli->setHeaders([
21+
'Host' => '127.0.0.1:1234',
22+
]);
23+
$cli->get('/');
24+
$pm->kill();
25+
});
26+
};
27+
28+
$pm->childFunc = function () use ($pm) {
29+
$server = new Swoole\Server('0.0.0.0', $pm->getFreePort(), SWOOLE_BASE);
30+
$server->set([
31+
'log_file' => '/dev/null',
32+
'open_eof_check' => true,
33+
'package_eof' => "\r\n\r\n",
34+
]);
35+
$server->on('Receive', function ($server, $fd, $reactor_id, $data) {
36+
echo $data;
37+
$server->close($fd);
38+
});
39+
$server->start();
40+
};
41+
42+
$pm->childFirst();
43+
$pm->run();
44+
45+
?>
46+
--EXPECT--
47+
GET http://127.0.0.1:1234/ HTTP/1.1
48+
Host: 127.0.0.1:1234
49+
Connection: keep-alive
50+
Accept-Encoding: gzip, deflate

0 commit comments

Comments
 (0)