+ } else if (path == "/test_args") {
+ if ((args["foo"] != "abc") || (args["bar"] != "1234") || (args["username"] != "johndoe")) {
+ sendErrorResponse(400, true, "bad arguments");
+ return;
+ }
+
+ string contentStr(BODY1);
+ stringstream d;
+ d << "HTTP/1.1 " << 200 << " " << reasonForCode(200) << "\r\n";
+ d << "Content-Length:" << contentStr.size() << "\r\n";
+ d << "\r\n"; // final CRLF to terminate the headers
+ d << contentStr;
+ push(d.str().c_str());
+ } else if (path == "/test_post") {
+ if (requestHeaders["Content-Type"] != "application/x-www-form-urlencoded") {
+ cerr << "bad content type: '" << requestHeaders["Content-Type"] << "'" << endl;
+ sendErrorResponse(400, true, "bad content type");
+ return;
+ }
+
+ requestContentLength = strutils::to_int(requestHeaders["Content-Length"]);
+ setByteCount(requestContentLength);
+ state = STATE_REQUEST_BODY;