本文整理汇总了C++中HttpMessage::getRequestMethod方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpMessage::getRequestMethod方法的具体用法?C++ HttpMessage::getRequestMethod怎么用?C++ HttpMessage::getRequestMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpMessage
的用法示例。
在下文中一共展示了HttpMessage::getRequestMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processForm
void
SipRedirectorMPT::displayForm(const HttpRequestContext& requestContext,
const HttpMessage& request,
HttpMessage*& response)
{
OsSysLog::add(FAC_SIP, PRI_DEBUG,
"%s::displayForm entered", mLogName.data());
UtlString method;
request.getRequestMethod(&method);
if (method.compareTo("POST") == 0)
{
processForm(requestContext, request, response);
}
else
{
response = new HttpMessage();
// Send 200 OK reply.
response->setResponseFirstHeaderLine(HTTP_PROTOCOL_VERSION,
HTTP_OK_CODE,
HTTP_OK_TEXT);
// Construct the HTML.
char buffer[FORM_SIZE];
sprintf(buffer, form, "", "Enter SIP URIs separated by newlines.");
// Insert the HTML into the response.
HttpBody* body = new HttpBody(buffer, -1, CONTENT_TYPE_TEXT_HTML);
response->setBody(body);
}
}
示例2: processForm
void
SipRedirectorGateway::displayForm(const HttpRequestContext& requestContext,
const HttpMessage& request,
HttpMessage*& response)
{
Os::Logger::instance().log(FAC_SIP, PRI_DEBUG,
"%s::displayForm entered", mLogName.data());
UtlString method;
request.getRequestMethod(&method);
if (method.compareTo("POST") == 0)
{
processForm(requestContext, request, response);
}
else
{
response = new HttpMessage();
// Send 200 OK reply.
response->setResponseFirstHeaderLine(HTTP_PROTOCOL_VERSION,
HTTP_OK_CODE,
HTTP_OK_TEXT);
// Insert the HTML into the response.
HttpBody* body = new HttpBody(form, -1, CONTENT_TYPE_TEXT_HTML);
response->setBody(body);
}
}
示例3: processRequest
void HttpServer::processRequest(const HttpMessage& request,
HttpMessage*& response,
OsConnectionSocket* connection
)
{
UtlString method;
response = NULL;
if(true) // used to be authorization check, but I don't want to change all indenting
{
request.getRequestMethod(&method);
method.toUpper();
UtlString uri;
request.getRequestUri(&uri);
UtlString uriFileName(uri);
ssize_t fileNameEnd = -1;
if(method.compareTo(HTTP_GET_METHOD) == 0)
{
fileNameEnd = uriFileName.first('?');
if(fileNameEnd > 0)
{
uriFileName.remove(fileNameEnd);
}
}
UtlString mappedUriFileName;
if (uriFileName.contains(".."))
{
OsSysLog::add(FAC_SIP, PRI_ERR, "HttpServer::processRequest "
"Disallowing URI: '%s' because it contains '..'",
uriFileName.data());
// Disallow relative path names going up for security reasons
mappedUriFileName.append("/");
}
else
{
OsSysLog::add(FAC_SIP, PRI_INFO, "HttpServer::processRequest "
"%s '%s'", method.data(), uriFileName.data());
// Map the file name
mapUri(mUriMaps, uriFileName.data(), mappedUriFileName);
}
// Build the request context
HttpRequestContext requestContext(method.data(),
uri.data(),
mappedUriFileName.data(),
NULL,
NULL, // was userid
connection
);
if(requestContext.methodIs(HTTP_POST_METHOD))
{
//Need to get the CGI/form variables from the body.
const HttpBody* body = request.getBody();
if(body && !body->isMultipart())
{
requestContext.extractPostCgiVariables(*body);
}
}
RequestProcessor* requestProcessorPtr = NULL;
HttpService* pService = NULL;
if( ( requestContext.methodIs(HTTP_GET_METHOD)
|| requestContext.methodIs(HTTP_POST_METHOD)
)
&& findRequestProcessor(uriFileName.data(), requestProcessorPtr))
{
// There is a request processor for this URI
requestProcessorPtr(requestContext, request, response);
}
else if ( ( requestContext.methodIs(HTTP_GET_METHOD)
|| requestContext.methodIs(HTTP_POST_METHOD)
|| requestContext.methodIs(HTTP_PUT_METHOD)
|| requestContext.methodIs(HTTP_DELETE_METHOD)
)
&& findHttpService(uriFileName.data(), pService))
{
pService->processRequest(requestContext, request, response);
}
else
{
processNotSupportedRequest(requestContext, request, response);
}
}
}