1#include <xrpl/server/detail/JSONRPCUtil.h>
3#include <xrpl/basics/Log.h>
4#include <xrpl/beast/utility/Journal.h>
5#include <xrpl/json/Output.h>
6#include <xrpl/protocol/BuildInfo.h>
7#include <xrpl/protocol/SystemParameters.h>
25 gmtime_r(&now, &nowGmt);
27 gmtime_s(&nowGmt, &now);
29 strftime(buffer,
sizeof(buffer),
"Date: %a, %d %b %Y %H:%M:%S +0000\r\n", &nowGmt);
36 JLOG(j.
trace()) <<
"HTTP Reply " << nStatus <<
" " << content;
38 if (content.
empty() && nStatus == 401)
40 output(
"HTTP/1.0 401 Authorization Required\r\n");
46 output(
"Server: " +
systemName() +
"-json-rpc/v1");
53 "WWW-Authenticate: Basic realm=\"jsonrpc\"\r\n"
54 "Content-Type: text/html\r\n"
55 "Content-Length: 296\r\n"
57 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 "
58 "Transitional//EN\"\r\n"
59 "\"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"
63 "<TITLE>Error</TITLE>\r\n"
64 "<META HTTP-EQUIV='Content-Type' "
65 "CONTENT='text/html; charset=ISO-8859-1'>\r\n"
67 "<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::function< void(boost::beast::string_view const &)> Output
std::string const & getFullVersionString()
Full server version string.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string getHTTPHeaderTimestamp()
void httpReply(int nStatus, std::string const &strMsg, json::Output const &, beast::Journal j)
static std::string const & systemName()