diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 5d70924c..cbb2f6d9 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -250,7 +250,7 @@ static inline string getProxyKey(const string &vhost,const string &app,const str Value makeMediaSourceJson(MediaSource &media){ Value item; item["schema"] = media.getSchema(); - item["vhost"] = media.getVhost(); + item[VHOST_KEY] = media.getVhost(); item["app"] = media.getApp(); item["stream"] = media.getId(); item["createStamp"] = (Json::UInt64) media.getCreateStamp(); diff --git a/server/WebHook.cpp b/server/WebHook.cpp index d1df3308..18126a8e 100755 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -113,6 +113,17 @@ const char *getContentType(const HttpArgs &value){ return "application/x-www-form-urlencoded"; } +string getVhost(const Value &value) { + const char *key = VHOST_KEY; + auto val = value.find(key, key + sizeof(VHOST_KEY) - 1); + return val ? val->asString() : ""; +} + +string getVhost(const HttpArgs &value) { + auto val = value.find(VHOST_KEY); + return val != value.end() ? val->second : ""; +} + void do_http_hook(const string &url,const ArgsType &body,const function &func){ GET_CONFIG(string, mediaServerId, General::kMediaServerId); GET_CONFIG(float, hook_timeoutSec, Hook::kTimeoutSec); @@ -123,6 +134,10 @@ void do_http_hook(const string &url,const ArgsType &body,const functionsetBody(bodyStr); requester->addHeader("Content-Type", getContentType(body)); + auto vhost = getVhost(body); + if (!vhost.empty()) { + requester->addHeader("X-VHOST", vhost); + } std::shared_ptr pTicker(new Ticker); requester->startRequester(url, [url, func, bodyStr, requester, pTicker](const SockException &ex, const string &status, @@ -147,7 +162,7 @@ void do_http_hook(const string &url,const ArgsType &body,const function weakSrc = sender.shared_from_this();