当前位置: 首页>>代码示例>>C++>>正文


C++ HttpMessage::getRequestMethod方法代码示例

本文整理汇总了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);
   }
}
开发者ID:chemeris,项目名称:sipxecs,代码行数:31,代码来源:SipRedirectorMPT.cpp

示例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);
   }
}
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:28,代码来源:SipRedirectorGateway.cpp

示例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);
        }
    }
}
开发者ID:LordGaav,项目名称:sipxecs,代码行数:90,代码来源:HttpServer.cpp


注:本文中的HttpMessage::getRequestMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。