Skip to content

Commit 71e490e

Browse files
committed
[fix] WebSocket sharing the same session in AdminProxy blocked HEAD requests from pipy workers
1 parent 8329b96 commit 71e490e

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/admin-proxy.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,16 @@ void AdminProxy::open(const std::string &ip, int port, const Options &options) {
161161
ppl_connect = ppl;
162162
}
163163

164+
m_session_selector = pjs::Method::make(
165+
"admin-proxy-session-selector",
166+
[](pjs::Context &, pjs::Object*, pjs::Value &ret) {
167+
ret.set(pjs::Object::make());
168+
}
169+
);
170+
164171
ppl_inbound->append(new http::Demux(nullptr))->add_sub_pipeline(ppl_request);
165172
ppl_request->append(new AdminProxyHandler(this))->add_sub_pipeline(ppl_forward);
166-
ppl_forward->append(new http::Mux(nullptr, nullptr))->add_sub_pipeline(ppl_connect);
173+
ppl_forward->append(new http::Mux(pjs::Function::make(m_session_selector), nullptr))->add_sub_pipeline(ppl_connect);
167174

168175
Listener::Options opts;
169176
auto listener = Listener::get(Port::Protocol::TCP, ip, port);

src/admin-proxy.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class AdminProxy {
8383
std::map<std::string, pjs::Ref<http::File>> m_www_file_cache;
8484
pjs::Ref<http::Directory> m_gui_files;
8585

86+
pjs::Ref<pjs::Method> m_session_selector;
8687
pjs::Ref<Message> m_response_not_found;
8788
pjs::Ref<Message> m_response_method_not_allowed;
8889

src/filters/dump.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ void Dump::process(Event *evt) {
100100
};
101101

102102
db.push(str, Log::format_header(Log::INFO, str, sizeof(str)));
103-
db.push(s_prefix_worker);
104-
db.push(str, str_fmt( "%d", WorkerThread::current()->index()));
103+
if (auto t = WorkerThread::current()) {
104+
db.push(s_prefix_worker);
105+
db.push(str, str_fmt( "%d", t->index()));
106+
}
105107
db.push(s_prefix_context);
106108
db.push(str, str_fmt( "%d", context()->id()));
107109
db.push(']');

0 commit comments

Comments
 (0)