20#include <xrpl/basics/Log.h>
21#include <xrpl/beast/utility/Journal.h>
22#include <xrpl/json/Output.h>
23#include <xrpl/protocol/BuildInfo.h>
24#include <xrpl/protocol/SystemParameters.h>
25#include <xrpl/server/detail/JSONRPCUtil.h>
45 gmtime_r(&now, &now_gmt);
47 gmtime_s(&now_gmt, &now);
52 "Date: %a, %d %b %Y %H:%M:%S +0000\r\n",
64 JLOG(j.
trace()) <<
"HTTP Reply " << nStatus <<
" " << content;
66 if (content.
empty() && nStatus == 401)
68 output(
"HTTP/1.0 401 Authorization Required\r\n");
74 output(
"Server: " +
systemName() +
"-json-rpc/v1");
81 "WWW-Authenticate: Basic realm=\"jsonrpc\"\r\n"
82 "Content-Type: text/html\r\n"
83 "Content-Length: 296\r\n"
85 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 "
86 "Transitional//EN\"\r\n"
87 "\"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"
91 "<TITLE>Error</TITLE>\r\n"
92 "<META HTTP-EQUIV='Content-Type' "
93 "CONTENT='text/html; charset=ISO-8859-1'>\r\n"
95 "<BODY><H1>401 Unauthorized.</H1></BODY>\r\n");
103 output(
"HTTP/1.1 200 OK\r\n");
106 output(
"HTTP/1.1 202 Accepted\r\n");
109 output(
"HTTP/1.1 400 Bad Request\r\n");
112 output(
"HTTP/1.1 401 Authorization Required\r\n");
115 output(
"HTTP/1.1 403 Forbidden\r\n");
118 output(
"HTTP/1.1 404 Not Found\r\n");
121 output(
"HTTP/1.1 405 Method Not Allowed\r\n");
124 output(
"HTTP/1.1 429 Too Many Requests\r\n");
127 output(
"HTTP/1.1 500 Internal Server Error\r\n");
130 output(
"HTTP/1.1 501 Not Implemented\r\n");
133 output(
"HTTP/1.1 503 Server is overloaded\r\n");
140 "Connection: Keep-Alive\r\n"
150 "Content-Type: application/json; charset=UTF-8\r\n");
152 output(
"Server: " +
systemName() +
"-json-rpc/");
A generic endpoint for log messages.
Stream trace() const
Severity stream access functions.
std::string const & getFullVersionString()
Full server version string.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void HTTPReply(int nStatus, std::string const &strMsg, Json::Output const &, beast::Journal j)
static std::string const & systemName()
std::string getHTTPHeaderTimestamp()