1#include <xrpl/basics/Log.h>
2#include <xrpl/beast/utility/Journal.h>
3#include <xrpl/json/Output.h>
4#include <xrpl/protocol/BuildInfo.h>
5#include <xrpl/protocol/SystemParameters.h>
6#include <xrpl/server/detail/JSONRPCUtil.h>
26 gmtime_r(&now, &now_gmt);
28 gmtime_s(&now_gmt, &now);
33 "Date: %a, %d %b %Y %H:%M:%S +0000\r\n",
45 JLOG(j.
trace()) <<
"HTTP Reply " << nStatus <<
" " << content;
47 if (content.
empty() && nStatus == 401)
49 output(
"HTTP/1.0 401 Authorization Required\r\n");
55 output(
"Server: " +
systemName() +
"-json-rpc/v1");
62 "WWW-Authenticate: Basic realm=\"jsonrpc\"\r\n"
63 "Content-Type: text/html\r\n"
64 "Content-Length: 296\r\n"
66 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 "
67 "Transitional//EN\"\r\n"
68 "\"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"
72 "<TITLE>Error</TITLE>\r\n"
73 "<META HTTP-EQUIV='Content-Type' "
74 "CONTENT='text/html; charset=ISO-8859-1'>\r\n"
76 "<BODY><H1>401 Unauthorized.</H1></BODY>\r\n");
84 output(
"HTTP/1.1 200 OK\r\n");
87 output(
"HTTP/1.1 202 Accepted\r\n");
90 output(
"HTTP/1.1 400 Bad Request\r\n");
93 output(
"HTTP/1.1 401 Authorization Required\r\n");
96 output(
"HTTP/1.1 403 Forbidden\r\n");
99 output(
"HTTP/1.1 404 Not Found\r\n");
102 output(
"HTTP/1.1 405 Method Not Allowed\r\n");
105 output(
"HTTP/1.1 429 Too Many Requests\r\n");
108 output(
"HTTP/1.1 500 Internal Server Error\r\n");
111 output(
"HTTP/1.1 501 Not Implemented\r\n");
114 output(
"HTTP/1.1 503 Server is overloaded\r\n");
121 "Connection: Keep-Alive\r\n"
131 "Content-Type: application/json; charset=UTF-8\r\n");
133 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()