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>
24 gmtime_r(&now, &now_gmt);
26 gmtime_s(&now_gmt, &now);
28 strftime(buffer,
sizeof(buffer),
"Date: %a, %d %b %Y %H:%M:%S +0000\r\n", &now_gmt);
35 JLOG(j.
trace()) <<
"HTTP Reply " << nStatus <<
" " << content;
37 if (content.
empty() && nStatus == 401)
39 output(
"HTTP/1.0 401 Authorization Required\r\n");
45 output(
"Server: " +
systemName() +
"-json-rpc/v1");
52 "WWW-Authenticate: Basic realm=\"jsonrpc\"\r\n"
53 "Content-Type: text/html\r\n"
54 "Content-Length: 296\r\n"
56 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 "
57 "Transitional//EN\"\r\n"
58 "\"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"
62 "<TITLE>Error</TITLE>\r\n"
63 "<META HTTP-EQUIV='Content-Type' "
64 "CONTENT='text/html; charset=ISO-8859-1'>\r\n"
66 "<BODY><H1>401 Unauthorized.</H1></BODY>\r\n");
74 output(
"HTTP/1.1 200 OK\r\n");
77 output(
"HTTP/1.1 202 Accepted\r\n");
80 output(
"HTTP/1.1 400 Bad Request\r\n");
83 output(
"HTTP/1.1 401 Authorization Required\r\n");
86 output(
"HTTP/1.1 403 Forbidden\r\n");
89 output(
"HTTP/1.1 404 Not Found\r\n");
92 output(
"HTTP/1.1 405 Method Not Allowed\r\n");
95 output(
"HTTP/1.1 429 Too Many Requests\r\n");
98 output(
"HTTP/1.1 500 Internal Server Error\r\n");
101 output(
"HTTP/1.1 501 Not Implemented\r\n");
104 output(
"HTTP/1.1 503 Server is overloaded\r\n");
111 "Connection: Keep-Alive\r\n"
121 "Content-Type: application/json; charset=UTF-8\r\n");
123 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)
std::string getHTTPHeaderTimestamp()
static std::string const & systemName()