Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions core/functional_tests/websocket_client/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class TestClientHandler final : public server::handlers::HttpHandlerBase {
return TestUnauth(request);
} else if (test_name == "connection_already_extracted") {
return TestConnectionAlreadyExtracted(request);
} else if (test_name == "remote_addr") {
return TestRemoteAddr(request);
}
return "Unknown test";
} catch (const std::exception& e) {
Expand All @@ -99,6 +101,16 @@ class TestClientHandler final : public server::handlers::HttpHandlerBase {
return client_.CreateRequest().url(fmt::format("ws://localhost:{}{}", port, uri)).PerformWebSocketHandshake();
}

std::string TestRemoteAddr(const server::http::HttpRequest& request) const {
const auto port = std::stoi(request.GetArg("port"));
auto conn = PerformWebSocket(request, "/echo").MakeWebSocketConnection();

const auto remote_port = conn->RemoteAddr().Port();
conn->Close(websocket::CloseStatus::kNormal);

return remote_port == port ? "OK" : fmt::format("FAIL: remote port is {}", remote_port);
}

std::string TestEcho(const server::http::HttpRequest& request) const {
auto conn = PerformWebSocket(request, "/echo").MakeWebSocketConnection();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
'nonblocking_write',
'unauth',
'connection_already_extracted',
'remote_addr',
],
)
async def test_client(service_client, service_port, test_name):
Expand Down
2 changes: 1 addition & 1 deletion core/src/clients/http/websocket_response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ std::shared_ptr<websocket::WebSocketConnection> WebSocketResponse::MakeWebSocket
}

auto socket = std::make_unique<engine::io::Socket>(socket_.GetNative());
auto addr = socket->Getsockname();
auto addr = socket->Getpeername();
auto config = websocket::Config{};

std::move(socket_).Release();
Expand Down
Loading