Add HTTP status codes section as part of the RPC implementation

This commit is contained in:
netkas 2024-09-02 15:08:57 -04:00
parent 70484154e0
commit 208aee2e39

View file

@ -59,6 +59,7 @@ This project is licensed under GNU Free Documentation License v1.3, see the [LIC
* [Response Object](#response-object) * [Response Object](#response-object)
* [Error Response Object](#error-response-object) * [Error Response Object](#error-response-object)
* [Error Codes](#error-codes) * [Error Codes](#error-codes)
* [HTTP Status Codes](#http-status-codes)
* [-1xxx: RPC Errors](#-1xxx-rpc-errors) * [-1xxx: RPC Errors](#-1xxx-rpc-errors)
* [-2xxx: Server Errors](#-2xxx-server-errors) * [-2xxx: Server Errors](#-2xxx-server-errors)
<!-- TOC --> <!-- TOC -->
@ -103,6 +104,8 @@ standards. Below are the modifications made to the JSON-RPC 2.0 specification:
string can be used, it is recommended to use CRC32 hex encoded strings for the request ID. string can be used, it is recommended to use CRC32 hex encoded strings for the request ID.
- Flattened the `error` object in the response object to include the error code and message directly under separate - Flattened the `error` object in the response object to include the error code and message directly under separate
fields instead of nesting them under the `error` object. fields instead of nesting them under the `error` object.
- Utilize HTTP status codes to indicate the status of the HTTP request-response cycle. For more details, refer to the
"HTTP Status Codes" section under [Error Codes](#error-codes).
### Notification & Request-Response Communication ### Notification & Request-Response Communication
@ -213,6 +216,24 @@ Error codes are globally defined codes that represent the type of error that occ
codes are categorized by the first digit, which represents the error category, followed by digits indicating the specific codes are categorized by the first digit, which represents the error category, followed by digits indicating the specific
error. The following are the error categories and their respective error codes: error. The following are the error categories and their respective error codes:
## HTTP Status Codes
HTTP status codes indicate the status of the HTTP request-response cycle. These response codes do not reflect the status
of the method call(s) but rather the status of the request or response itself, independent of the method call(s).
The client should first check the HTTP status code before parsing the response body. If the status code is not 200,
the client should not parse the response body, as it will contain a non-JSON encoded error message. For example,
if the status code is 400, the response body will contain a message like "Bad Request," which the client should
display to the user as the error message.
| Code | Status | Description |
|------|--------------|----------------------------------------------------------------------------------------|
| 200 | OK | The RPC request was successful. |
| 400 | Bad Request | The RPC request was invalid or missing required fields. |
| 500 | Server Error | An internal server error occurred during the RPC process or the server is unavailable. |
## -1xxx: RPC Errors ## -1xxx: RPC Errors
RPC errors are errors that occur during the remote procedure call (RPC) process. These errors are related to the RPC errors are errors that occur during the remote procedure call (RPC) process. These errors are related to the