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);
30 strftime(buffer,
sizeof(buffer),
"Date: %a, %d %b %Y %H:%M:%S +0000\r\n", &now_gmt);
37 JLOG(j.
trace()) <<
"HTTP Reply " << nStatus <<
" " << content;
39 if (content.
empty() && nStatus == 401)
41 output(
"HTTP/1.0 401 Authorization Required\r\n");
47 output(
"Server: " +
systemName() +
"-json-rpc/v1");
54 "WWW-Authenticate: Basic realm=\"jsonrpc\"\r\n"
55 "Content-Type: text/html\r\n"
56 "Content-Length: 296\r\n"
58 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 "
59 "Transitional//EN\"\r\n"
60 "\"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"
64 "<TITLE>Error</TITLE>\r\n"
65 "<META HTTP-EQUIV='Content-Type' "
66 "CONTENT='text/html; charset=ISO-8859-1'>\r\n"
68 "<BODY><H1>401 Unauthorized.</H1></BODY>\r\n");
76 output(
"HTTP/1.1 200 OK\r\n");
79 output(
"HTTP/1.1 202 Accepted\r\n");
82 output(
"HTTP/1.1 400 Bad Request\r\n");
85 output(
"HTTP/1.1 401 Authorization Required\r\n");
88 output(
"HTTP/1.1 403 Forbidden\r\n");
91 output(
"HTTP/1.1 404 Not Found\r\n");
94 output(
"HTTP/1.1 405 Method Not Allowed\r\n");
97 output(
"HTTP/1.1 429 Too Many Requests\r\n");
100 output(
"HTTP/1.1 500 Internal Server Error\r\n");
103 output(
"HTTP/1.1 501 Not Implemented\r\n");
106 output(
"HTTP/1.1 503 Server is overloaded\r\n");
113 "Connection: Keep-Alive\r\n"
123 "Content-Type: application/json; charset=UTF-8\r\n");
125 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()