| 106 | |
| 107 | C_ATTR(headers, :Local :AutoArgs) |
| 108 | void headers(Context *c) |
| 109 | { |
| 110 | QUrlQuery ret; |
| 111 | auto headers = c->request()->headers().data(); |
| 112 | std::ranges::sort(headers, |
| 113 | [](const Headers::HeaderKeyValue &a, const Headers::HeaderKeyValue &b) { |
| 114 | return a.key < b.key; |
| 115 | }); |
| 116 | |
| 117 | for (const auto &header : std::as_const(headers)) { |
| 118 | ret.addQueryItem(QString::fromLatin1(header.key), QString::fromLatin1(header.value)); |
| 119 | } |
| 120 | c->response()->setBody(ret.toString(QUrl::FullyEncoded)); |
| 121 | } |
| 122 | |
| 123 | C_ATTR(userAgent, :Local :AutoArgs) |
| 124 | void userAgent(Context *c) { c->response()->setBody(c->request()->userAgent()); } |