本文整理汇总了C++中WebRequest::requestMethod方法的典型用法代码示例。如果您正苦于以下问题:C++ WebRequest::requestMethod方法的具体用法?C++ WebRequest::requestMethod怎么用?C++ WebRequest::requestMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebRequest
的用法示例。
在下文中一共展示了WebRequest::requestMethod方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse
void CgiParser::parse(WebRequest& request, ReadOption readOption)
{
/*
* TODO: optimize this ...
*/
request_ = &request;
::int64_t len = request.contentLength();
std::string type = request.contentType();
std::string meth = request.requestMethod();
request.postDataExceeded_ = (len > maxPostData_ ? len : 0);
std::string queryString = request.queryString();
// XDomainRequest cannot set a contentType header, we therefore pass it
// as a request parameter
if (readOption != ReadHeadersOnly && meth == "POST"
&& (type.find("application/x-www-form-urlencoded") == 0
|| queryString.find("&contentType=x-www-form-urlencoded")
!= std::string::npos)) {
/*
* TODO: parse this stream-based to avoid the malloc here. For now
* we protect the maximum that can be POST'ed as form data.
*/
if (len > 5*1024*1024)
throw WException("Oversized application/x-www-form-urlencoded ("
+ boost::lexical_cast<std::string>(len) + ")");
char *buf = new char[len + 1];
request.in().read(buf, len);
if (request.in().gcount() != (int)len) {
delete[] buf;
throw WException("Unexpected short read.");
}
buf[len] = 0;
// This is a special Wt feature, I do not think it standard.
// For POST, parameters in url-encoded URL are still parsed.
if (!queryString.empty())
queryString += '&';
queryString += buf;
delete[] buf;
}
LOG_DEBUG("queryString (len=" << len << "): " << queryString);
if (!queryString.empty())
Http::Request::parseFormUrlEncoded(queryString, request_->parameters_);
if (readOption != ReadHeadersOnly && type.find("multipart/form-data") == 0) {
if (meth != "POST") {
throw WException("Invalid method for multipart/form-data: " + meth);
}
if (!request.postDataExceeded_)
readMultipartData(request, type, len);
else if (readOption == ReadBodyAnyway) {
for (;len > 0;) {
::int64_t toRead = std::min(::int64_t(BUFSIZE), len);
request.in().read(buf_, toRead);
if (request.in().gcount() != (::int64_t)toRead)
throw WException("CgiParser: short read");
len -= toRead;
}
}
}
}