out += "\\r";
} else if (ch == '\t') {
out += "\\t";
- } else if (static_cast<uint8_t>(ch) <= 0x1f || static_cast<uint8_t>(ch) >= 0x7f) {
+ } else if (static_cast<uint8_t>(ch) <= 0x1f) {
char buf[8];
snprintf(buf, sizeof buf, "\\u%04x", ch);
out += buf;
+ } else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1]) == 0x80
+ && static_cast<uint8_t>(value[i+2]) == 0xa8) {
+ out += "\\u2028";
+ i += 2;
+ } else if (static_cast<uint8_t>(ch) == 0xe2 && static_cast<uint8_t>(value[i+1]) == 0x80
+ && static_cast<uint8_t>(value[i+2]) == 0xa9) {
+ out += "\\u2029";
+ i += 2;
} else {
out += ch;
}
}
if (d_loglevel >= WebServer::LogLevel::Normal) {
- SLOG(g_log<<Logger::Notice<<logprefix<<remote<<" \""<<req.method<<" "<<YaHTTP::Utility::encodeURL(req.url.path)<<" HTTP/"<<req.versionStr(req.version)<<"\" "<<resp.status<<" "<<reply.size()<<endl,
+ SLOG(g_log<<Logger::Notice<<logprefix<<remote<<" \""<<req.method<<" "<<req.url.path<<" HTTP/"<<req.versionStr(req.version)<<"\" "<<resp.status<<" "<<reply.size()<<endl,
d_slog->info(Logr::Info, "Request", "remote", Logging::Loggable(remote), "method", Logging::Loggable(req.method),
"urlpath", Logging::Loggable(req.url.path), "HTTPVersion", Logging::Loggable(req.versionStr(req.version)),
"status", Logging::Loggable(resp.status), "respsize", Logging::Loggable(reply.size())));
import operator
import requests
import unittest
-import socket
from test_helper import ApiTestCase, is_auth, is_recursor, is_auth_lmdb
self.assertIn('daemon', data)
def test_read_statistics(self):
- # Use low-level API as we want to create an invalid request to test log line encoding
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM);
- sock.connect((self.server_address, self.server_port))
- sock.send(b'GET /binary\x00\x01\xeb HTTP/1.0\r\n')
- sock.close()
r = self.session.get(self.url("/api/v1/servers/localhost/statistics"))
self.assert_success_json(r)
data = r.json()
self.assertIn('uptime', [e['name'] for e in data])
print(data)
if is_auth():
- qtype_stats, respsize_stats, queries_stats, rcode_stats, logmessages = None, None, None, None, None
+ qtype_stats, respsize_stats, queries_stats, rcode_stats = None, None, None, None
for elem in data:
if elem['type'] == 'MapStatisticItem' and elem['name'] == 'response-by-qtype':
qtype_stats = elem['value']
queries_stats = elem['value']
elif elem['type'] == 'MapStatisticItem' and elem['name'] == 'response-by-rcode':
rcode_stats = elem['value']
- elif elem['type'] == 'RingStatisticItem' and elem['name'] == 'logmessages':
- logmessages = elem['value']
self.assertIn('A', [e['name'] for e in qtype_stats])
self.assertIn('80', [e['name'] for e in respsize_stats])
self.assertIn('example.com/A', [e['name'] for e in queries_stats])
self.assertIn('No Error', [e['name'] for e in rcode_stats])
- self.assertTrue(logmessages[0]['name'].startswith('[webserver]'))
else:
qtype_stats, respsize_stats, rcode_stats = None, None, None
for elem in data: