73 |
|
return 0; |
74 |
|
} |
75 |
|
|
76 |
< |
Smersh::Smersh(istream& sin, ostream& sout) |
76 |
> |
Smersh::Smersh(istream& sin, ostream& sout, const Environment& env) |
77 |
|
{ |
78 |
< |
parse(sin); |
78 |
> |
parse(sin, env); |
79 |
|
smersh(sout); |
80 |
|
} |
81 |
|
|
82 |
< |
void Smersh::parse(istream& sin) |
82 |
> |
Environment Smersh::env; |
83 |
> |
|
84 |
> |
void Smersh::parse(istream& sin, const Environment& env) |
85 |
|
{ |
86 |
< |
stringstream query(sgetenv("QUERY_STRING")); |
86 |
> |
stringstream query(env.get("QUERY_STRING")); |
87 |
|
|
88 |
< |
if (sgetenv("REQUEST_METHOD") == "POST") |
88 |
> |
if (env.get("REQUEST_METHOD") == "POST") |
89 |
|
{ |
90 |
< |
streamsize length(lexical_cast<streamsize>(sgetenv("CONTENT_LENGTH"))); |
91 |
< |
char* content = new char[length]; |
90 |
> |
streamsize length(lexical_cast<streamsize>(env.get("CONTENT_LENGTH"))); |
91 |
> |
char* content(new char[length]); |
92 |
|
|
93 |
|
sin.read(content, length); |
94 |
|
query.write(content, length); |
111 |
|
|
112 |
|
void Smersh::smersh(ostream& sout) |
113 |
|
{ |
114 |
< |
sout << "Content-Type: text/html\n\n"; |
114 |
> |
sout << "Content-Type: text/html; charset=UTF-8\n\n"; |
115 |
|
|
116 |
|
vector<Person> people(1); |
117 |
|
|