mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-19 18:03:50 +00:00
Merge pull request #3782 from mloy/fix_websocket_without_path_with_test
Fix websocket without path with test
This commit is contained in:
commit
1b8a352480
14
RELICENSE/mloy.md
Normal file
14
RELICENSE/mloy.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Permission to Relicense under MPLv2
|
||||||
|
|
||||||
|
This is a statement by Matthias Loy
|
||||||
|
that grants permission to relicense its copyrights in the libzmq C++
|
||||||
|
library (ZeroMQ) under the Mozilla Public License v2 (MPLv2).
|
||||||
|
|
||||||
|
A portion of the commits made by the Github handle "mloy", with
|
||||||
|
commit author "Matthias Loy", are copyright of Matthias Loy.
|
||||||
|
This document hereby grants the libzmq project team to relicense libzmq,
|
||||||
|
including all past, present and future contributions of the author listed above.
|
||||||
|
|
||||||
|
Matthias Loy
|
||||||
|
2020/01/18
|
||||||
|
|
@ -99,14 +99,17 @@ int zmq::ws_address_t::resolve (const char *name_, bool local_, bool ipv6_)
|
|||||||
}
|
}
|
||||||
_host = std::string (name_, delim - name_);
|
_host = std::string (name_, delim - name_);
|
||||||
|
|
||||||
// find the path part, which is optional
|
// find the path part, which is optional
|
||||||
delim = strrchr (name_, '/');
|
delim = strrchr (name_, '/');
|
||||||
if (delim)
|
std::string host_name;
|
||||||
|
if (delim) {
|
||||||
_path = std::string (delim);
|
_path = std::string (delim);
|
||||||
else
|
// remove the path, otherwise resolving the port will fail with wildcard
|
||||||
|
host_name = std::string (name_, delim - name_);
|
||||||
|
} else {
|
||||||
_path = std::string ("/");
|
_path = std::string ("/");
|
||||||
// remove the path, otherwise resolving the port will fail with wildcard
|
host_name = name_;
|
||||||
std::string host_port = std::string (name_, delim - name_);
|
}
|
||||||
|
|
||||||
ip_resolver_options_t resolver_opts;
|
ip_resolver_options_t resolver_opts;
|
||||||
resolver_opts.bindable (local_)
|
resolver_opts.bindable (local_)
|
||||||
@ -118,7 +121,7 @@ int zmq::ws_address_t::resolve (const char *name_, bool local_, bool ipv6_)
|
|||||||
|
|
||||||
ip_resolver_t resolver (resolver_opts);
|
ip_resolver_t resolver (resolver_opts);
|
||||||
|
|
||||||
return resolver.resolve (&_address, host_port.c_str ());
|
return resolver.resolve (&_address, host_name.c_str ());
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq::ws_address_t::to_string (std::string &addr_) const
|
int zmq::ws_address_t::to_string (std::string &addr_) const
|
||||||
|
@ -212,8 +212,14 @@ int zmq::ws_listener_t::set_local_address (const char *addr_)
|
|||||||
|
|
||||||
// remove the path, otherwise resolving the port will fail with wildcard
|
// remove the path, otherwise resolving the port will fail with wildcard
|
||||||
const char *delim = strrchr (addr_, '/');
|
const char *delim = strrchr (addr_, '/');
|
||||||
std::string host_port = std::string (addr_, delim - addr_);
|
std::string host_address;
|
||||||
if (create_socket (host_port.c_str ()) == -1)
|
if (delim) {
|
||||||
|
host_address = std::string (addr_, delim - addr_);
|
||||||
|
} else {
|
||||||
|
host_address = addr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (create_socket (host_address.c_str ()) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,25 @@ void test_roundtrip ()
|
|||||||
test_context_socket_close (sb);
|
test_context_socket_close (sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_roundtrip_without_path ()
|
||||||
|
{
|
||||||
|
char connect_address[MAX_SOCKET_STRING];
|
||||||
|
size_t addr_length = sizeof (connect_address);
|
||||||
|
void *sb = test_context_socket (ZMQ_REP);
|
||||||
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_bind (sb, "ws://*:*"));
|
||||||
|
TEST_ASSERT_SUCCESS_ERRNO (
|
||||||
|
zmq_getsockopt (sb, ZMQ_LAST_ENDPOINT, connect_address, &addr_length));
|
||||||
|
|
||||||
|
void *sc = test_context_socket (ZMQ_REQ);
|
||||||
|
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sc, connect_address));
|
||||||
|
|
||||||
|
bounce (sb, sc);
|
||||||
|
|
||||||
|
test_context_socket_close (sc);
|
||||||
|
test_context_socket_close (sb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void test_heartbeat ()
|
void test_heartbeat ()
|
||||||
{
|
{
|
||||||
char connect_address[MAX_SOCKET_STRING + strlen ("/heartbeat")];
|
char connect_address[MAX_SOCKET_STRING + strlen ("/heartbeat")];
|
||||||
@ -202,6 +221,7 @@ int main ()
|
|||||||
|
|
||||||
UNITY_BEGIN ();
|
UNITY_BEGIN ();
|
||||||
RUN_TEST (test_roundtrip);
|
RUN_TEST (test_roundtrip);
|
||||||
|
RUN_TEST (test_roundtrip_without_path);
|
||||||
RUN_TEST (test_short_message);
|
RUN_TEST (test_short_message);
|
||||||
RUN_TEST (test_large_message);
|
RUN_TEST (test_large_message);
|
||||||
RUN_TEST (test_heartbeat);
|
RUN_TEST (test_heartbeat);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user