本文整理汇总了C++中HTTPRequest::readParams方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPRequest::readParams方法的具体用法?C++ HTTPRequest::readParams怎么用?C++ HTTPRequest::readParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPRequest
的用法示例。
在下文中一共展示了HTTPRequest::readParams方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
int Webserver::process(FILE* f) {
char buf[4096];
char *method;
char *path;
char *protocol;
if (!fgets(buf, sizeof(buf), f))
return -1;
printf("%s", buf);
char* bufp = buf;
method = strsep(&bufp, " ");
path = strsep(&bufp, " ");
protocol = strsep(&bufp, "\r");
if (!method || !path || !protocol)
return -1;
// Extract request
HTTPRequest request;
request.method = string(method);
request.path = string(path);
request.readHeaders(f);
request.writeHeaders(stdout);
request.readParams(f);
request.setBody(f);
// Find and execute action
Action* action = actions[path];
if (action == NULL) {
action = file_action;
}
HTTPResponse response = action->execute(request);
response.addHeader("Server", string("RayGay Renderslave ") + string(VERSION));
request.addHeader("Date", WebUtil::formatDate(time(NULL)));
// Send response
fseek(f, 0, SEEK_CUR); // Force change of stream direction
fprintf(f, "HTTP/1.0 %d %s\r\n", response.status, response.statusString().c_str());
response.writeHeaders(f);
response.writeBody(f);
return 0;
}