-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathechoRequest.hxx
More file actions
36 lines (25 loc) · 880 Bytes
/
echoRequest.hxx
File metadata and controls
36 lines (25 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef INCLUDED_ECHO_REQUEST_HXX
#define INCLUDED_ECHO_REQUEST_HXX
#include "synchronicity.hxx"
#include <string>
#include <sstream>
template <typename TRequest>
std::string echoRequest (const Synchronicity& synchronicity, const TRequest& request)
{
std::stringstream responseBody;
responseBody << "<body>";
responseBody << "Received " << synchronicity << " request.:\n";
responseBody << "Headers:\n";
auto headers_range = request.headers;
for (auto header: headers_range) {
responseBody << "\t" << header.name << ":" << header.value << "\n";
}
responseBody << "\n";
responseBody << "Destination: " << request.destination << "\n";
responseBody << "Body:\n" << request.body <<"\n\n";
responseBody << "</body>\n";
return responseBody.str();
}
#endif
/* vim:set tabstop=4 shiftwidth=4 fo=cqwan autoindent : */
/* makeprg=make\ -C\ ~/tmp/build-try-https */