2017-04-04 20:58:40 +01:00
|
|
|
#include "incredis/incredis.hpp"
|
|
|
|
#include "submit_form_response.hpp"
|
2017-04-05 08:41:49 +01:00
|
|
|
#include "cgi_env.hpp"
|
2017-04-04 20:58:40 +01:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <iterator>
|
|
|
|
|
|
|
|
//www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4150.pdf
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
} //unnamed namespace
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
//std::cout << "Content-type:text/plain\n\n";
|
|
|
|
|
|
|
|
redis::IncRedis incredis("127.0.0.1", 6379);
|
|
|
|
|
|
|
|
tawashi::SubmitFormResponse resp;
|
|
|
|
resp.send();
|
|
|
|
|
2017-04-05 08:41:49 +01:00
|
|
|
tawashi::CGIEnv cgi_env;
|
|
|
|
for (auto& pair : cgi_env.query_string()) {
|
2017-04-04 20:58:40 +01:00
|
|
|
std::cout << "first:\t\"" << pair.first <<
|
|
|
|
"\"\tsecond:\t\"" << pair.second << "\"\n";
|
|
|
|
}
|
|
|
|
|
2017-04-05 08:41:49 +01:00
|
|
|
const std::size_t in_len = cgi_env.content_length();
|
2017-04-04 20:58:40 +01:00
|
|
|
std::cout << "\n<br>\n";
|
|
|
|
std::cout << "Content length: \"" << in_len << "\"\n<br>\n";
|
|
|
|
|
2017-04-05 08:41:49 +01:00
|
|
|
//for (std::size_t z = 0; z < env.size(); ++z) {
|
|
|
|
// std::cout << tawashi::CGIVars::_from_integral(z) << " = \"" << env[z] << "\"<br>\n";
|
|
|
|
//}
|
2017-04-04 20:58:40 +01:00
|
|
|
std::string input;
|
|
|
|
if (in_len > 0)
|
|
|
|
std::copy_n(std::istream_iterator<char>(std::cin), in_len, std::back_inserter(input));
|
|
|
|
std::cout << input << '\n';
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|