mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
relay/api: return HTTP error 404 instead of 400 when the buffer is not found in resources completion and input
This commit is contained in:
@@ -41,6 +41,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
- irc: fix warning on creation of irc.msgbuffer option when the server name contains upper case letters ([#2281](https://github.com/weechat/weechat/issues/2281))
|
||||
- irc: display a warning for each unknown or invalid server option in commands /connect and /server
|
||||
- relay/api: fix crash when an invalid HTTP request is received from a client
|
||||
- relay/api: return HTTP error 404 instead of 400 when the buffer is not found in resources completion and input
|
||||
|
||||
## Version 4.7.1 (2025-08-16)
|
||||
|
||||
|
||||
@@ -797,7 +797,7 @@ RELAY_API_PROTOCOL_CALLBACK(input)
|
||||
{
|
||||
relay_api_msg_send_error_json (
|
||||
client,
|
||||
RELAY_HTTP_400_BAD_REQUEST, NULL,
|
||||
RELAY_HTTP_404_NOT_FOUND, NULL,
|
||||
"Buffer \"%s\" not found",
|
||||
ptr_buffer_name);
|
||||
cJSON_Delete (json_body);
|
||||
@@ -819,7 +819,7 @@ RELAY_API_PROTOCOL_CALLBACK(input)
|
||||
{
|
||||
relay_api_msg_send_error_json (
|
||||
client,
|
||||
RELAY_HTTP_400_BAD_REQUEST, NULL,
|
||||
RELAY_HTTP_404_NOT_FOUND, NULL,
|
||||
"Buffer \"%lld\" not found",
|
||||
(long long)cJSON_GetNumberValue (json_buffer_id));
|
||||
cJSON_Delete (json_body);
|
||||
@@ -924,7 +924,7 @@ RELAY_API_PROTOCOL_CALLBACK(completion)
|
||||
{
|
||||
relay_api_msg_send_error_json (
|
||||
client,
|
||||
RELAY_HTTP_400_BAD_REQUEST, NULL,
|
||||
RELAY_HTTP_404_NOT_FOUND, NULL,
|
||||
"Buffer \"%s\" not found",
|
||||
ptr_buffer_name);
|
||||
cJSON_Delete (json_body);
|
||||
@@ -946,7 +946,7 @@ RELAY_API_PROTOCOL_CALLBACK(completion)
|
||||
{
|
||||
relay_api_msg_send_error_json (
|
||||
client,
|
||||
RELAY_HTTP_400_BAD_REQUEST, NULL,
|
||||
RELAY_HTTP_404_NOT_FOUND, NULL,
|
||||
"Buffer \"%lld\" not found",
|
||||
(long long)cJSON_GetNumberValue (json_buffer_id));
|
||||
cJSON_Delete (json_body);
|
||||
|
||||
@@ -614,6 +614,12 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'404':
|
||||
description: Buffer not found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
security:
|
||||
- password: []
|
||||
/completion:
|
||||
@@ -677,6 +683,12 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'404':
|
||||
description: Buffer not found
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
security:
|
||||
- password: []
|
||||
/ping:
|
||||
|
||||
@@ -622,7 +622,6 @@ TEST(RelayApiProtocolWithClient, CbCompletion)
|
||||
|
||||
/* error: no body */
|
||||
test_client_recv_http ("POST /api/completion", NULL, NULL);
|
||||
WEE_CHECK_HTTP_CODE(400, "Bad Request");
|
||||
STRCMP_EQUAL("HTTP/1.1 400 Bad Request\r\n"
|
||||
"Access-Control-Allow-Origin: *\r\n"
|
||||
"Content-Type: application/json; charset=utf-8\r\n"
|
||||
@@ -636,8 +635,7 @@ TEST(RelayApiProtocolWithClient, CbCompletion)
|
||||
NULL,
|
||||
"{\"buffer_name\": \"invalid\", "
|
||||
"\"command\": \"test\"}");
|
||||
WEE_CHECK_HTTP_CODE(400, "Bad Request");
|
||||
STRCMP_EQUAL("HTTP/1.1 400 Bad Request\r\n"
|
||||
STRCMP_EQUAL("HTTP/1.1 404 Not Found\r\n"
|
||||
"Access-Control-Allow-Origin: *\r\n"
|
||||
"Content-Type: application/json; charset=utf-8\r\n"
|
||||
"Content-Length: 40\r\n"
|
||||
@@ -717,7 +715,7 @@ TEST(RelayApiProtocolWithClient, CbInput)
|
||||
NULL,
|
||||
"{\"buffer_name\": \"invalid\", "
|
||||
"\"command\": \"/print test\"}");
|
||||
STRCMP_EQUAL("HTTP/1.1 400 Bad Request\r\n"
|
||||
STRCMP_EQUAL("HTTP/1.1 404 Not Found\r\n"
|
||||
"Access-Control-Allow-Origin: *\r\n"
|
||||
"Content-Type: application/json; charset=utf-8\r\n"
|
||||
"Content-Length: 40\r\n"
|
||||
|
||||
Reference in New Issue
Block a user