diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2024-03-31 16:57:40 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2024-04-07 13:18:13 +0200 |
commit | cb785d5035b88e63f356726f6f50039617f8c5c5 (patch) | |
tree | 34d5e6d0e724a0cdde1dc94430034a76d2e2d82d /src/plugins | |
parent | 9d7e887d8e9122114ca43fa0fa7440fd1cd221ab (diff) | |
download | weechat-cb785d5035b88e63f356726f6f50039617f8c5c5.zip |
relay/api: add "request" and "request_body" in response when connected via websocket (issue #2066)
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/relay/api/relay-api-msg.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/plugins/relay/api/relay-api-msg.c b/src/plugins/relay/api/relay-api-msg.c index 6f5cc30c6..d6af528f9 100644 --- a/src/plugins/relay/api/relay-api-msg.c +++ b/src/plugins/relay/api/relay-api-msg.c @@ -121,9 +121,9 @@ relay_api_msg_send_json_internal (struct t_relay_client *client, cJSON *json_body) { cJSON *json, *json_event; - int num_bytes; + int num_bytes, length; const char *ptr_id; - char *string, *error; + char *string, *error, *request; long long id; if (!client || !message) @@ -165,6 +165,30 @@ relay_api_msg_send_json_internal (struct t_relay_client *client, cJSON_AddItemToObject (json, "event", json_event); } } + else + { + length = ((client->http_req->method) ? strlen (client->http_req->method) : 0) + + 1 + + ((client->http_req->path) ? strlen (client->http_req->path) : 0) + + 1; + request = malloc (length); + if (request) + { + snprintf ( + request, length, + "%s%s%s", + (client->http_req->method) ? client->http_req->method : "", + (client->http_req->method) ? " " : "", + (client->http_req->path) ? client->http_req->path : ""); + cJSON_AddItemToObject (json, "request", + cJSON_CreateString (request)); + cJSON_AddItemToObject ( + json, "request_body", + (client->http_req->body) ? + cJSON_Parse (client->http_req->body) :cJSON_CreateNull ()); + free (request); + } + } if (json_body) { cJSON_AddItemToObject (json, "body_type", |