本文整理汇总了C++中HttpReq::getMethod方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpReq::getMethod方法的具体用法?C++ HttpReq::getMethod怎么用?C++ HttpReq::getMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpReq
的用法示例。
在下文中一共展示了HttpReq::getMethod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildFcgiEnv
int HttpCgiTool::buildFcgiEnv(FcgiEnv *pEnv, HttpSession *pSession)
{
static const char *SP_ENVs[] =
{
"\017\010SERVER_PROTOCOLHTTP/1.1",
"\017\010SERVER_PROTOCOLHTTP/1.0",
"\017\010SERVER_PROTOCOLHTTP/0.9"
};
static const char *RM_ENVs[10] =
{
"\016\007REQUEST_METHODUNKNOWN",
"\016\007REQUEST_METHODOPTIONS",
"\016\003REQUEST_METHODGET",
"\016\004REQUEST_METHODHEAD",
"\016\004REQUEST_METHODPOST",
"\016\003REQUEST_METHODPUT",
"\016\006REQUEST_METHODDELETE",
"\016\005REQUEST_METHODTRACE",
"\016\007REQUEST_METHODCONNECT",
"\016\004REQUEST_METHODMOVE"
};
static int RM_ENV_LEN[10] =
{ 23, 23, 19, 20, 20, 19, 22, 21, 23, 20 };
HttpReq *pReq = pSession->getReq();
int n;
pEnv->add(GISS_ENV, GISS_ENV_LEN);
n = pReq->getVersion();
pEnv->add(SP_ENVs[n], 25);
n = pReq->getMethod();
if (n < 10)
pEnv->add(RM_ENVs[n], RM_ENV_LEN[n]);
else
pEnv->add("REQUEST_METHOD", 016, HttpMethod::get(n),
HttpMethod::getLen(n));
addSpecialEnv(pEnv, pReq);
buildCommonEnv(pEnv, pSession);
addHttpHeaderEnv(pEnv, pReq);
return 0;
}
示例2: buildEnv
int HttpCgiTool::buildEnv( IEnv* pEnv, HttpConnection* pConn )
{
HttpReq * pReq = pConn->getReq();
int n;
pEnv->add( "GATEWAY_INTERFACE",17, "CGI/1.1", 7 );
if ( getenv( "PATH" ) == NULL )
{
pEnv->add( "PATH", 4, DEFAULT_PATH, DEFAULT_PATHLEN );
}
n = pReq->getVersion();
pEnv->add( "SERVER_PROTOCOL", 15,
HttpVer::getVersionString( n ),
HttpVer::getVersionStringLen( n ));
const char * pServerStr;
pServerStr = HttpServerVersion::getVersion();
n = HttpServerVersion::getVersionLen();
pEnv->add( "SERVER_SOFTWARE", 15, pServerStr, n);
n = pReq->getMethod();
pEnv->add( "REQUEST_METHOD", 14, HttpMethod::get( n ),
HttpMethod::getLen( n ));
// //FIXME: do nslookup
//
// tmp = dnslookup(r->cn->peer.sin_addr, r->c->dns);
// if (tmp) {
// ADD_ENV(pEnv, "REMOTE_HOST", tmp);
// free(tmp);
// }
//
// //ADD_ENV(pEnv, "REMOTE_HOST", achTemp );
addSpecialEnv( pEnv, pReq );
buildCommonEnv( pEnv, pConn );
addHttpHeaderEnv( pEnv, pReq );
pEnv->add( 0, 0, 0, 0);
return 0;
}
示例3: getReqVar
int RequestVars::getReqVar( HttpSession *pSession, int type, char * &pValue, int bufLen)
{
HttpReq * pReq = pSession->getReq();
int i;
char *p;
if ( type < REF_STRING )
{
pValue = (char *)pReq->getHeader( type );
if ( *pValue )
return pReq->getHeaderLen( type );
else
return 0;
}
switch( type )
{
case REF_REMOTE_HOST:
//FIXME: use remote addr for now
case REF_REMOTE_ADDR:
pValue = (char *)pSession->getPeerAddrString();
return pSession->getPeerAddrStrLen();
case REF_REMOTE_PORT:
return snprintf( pValue, bufLen, "%hu", pSession->getRemotePort() );
case REF_REMOTE_USER:
pValue = (char *)pReq->getAuthUser();
return strlen( pValue );
case REF_REMOTE_IDENT:
//do not support;
return 0;
case REF_REQ_METHOD:
i = pReq->getMethod();
strcpy(pValue, HttpMethod::get( i ) );
return HttpMethod::getLen( i );
case REF_QUERY_STRING:
pValue = (char *)pReq->getQueryString();
return pReq->getQueryStringLen();
case REF_AUTH_TYPE:
//FIXME: hard code for now
strncpy( pValue, "Basic", 6 );
return 5;
case REF_REQUST_FN:
case REF_SCRIPTFILENAME:
case REF_SCRIPT_BASENAME:
case REF_REQ_BASENAME:
{
const AutoStr2 * psTemp = pReq->getRealPath();
if ( psTemp )
{
if (( type == REF_SCRIPT_BASENAME )||
( type == REF_REQ_BASENAME ))
{
const char * pEnd = psTemp->c_str() + psTemp->len();
pValue = (char *)pEnd;
while( pValue[-1] != '/' )
--pValue;
return pEnd - pValue;
}
pValue = (char *)psTemp->c_str();
return psTemp->len();
}
else
return 0;
}
case REF_SCRIPT_UID:
case REF_SCRIPT_GID:
case REF_SCRIPT_USERNAME:
case REF_SCRIPT_GRPNAME:
case REF_SCRIPT_MODE:
{
const AutoStr2 * psTemp = pReq->getRealPath();
if ( psTemp )
{
struct stat& st = pReq->getFileStat();
if ( type == REF_SCRIPT_UID )
{
return snprintf( pValue, bufLen, "%d", st.st_uid );
}
else if ( type == REF_SCRIPT_GID )
{
return snprintf( pValue, bufLen, "%d", st.st_gid );
}
else if ( type == REF_SCRIPT_MODE )
{
return snprintf( pValue, bufLen, "%o", st.st_mode );
}
else if ( type == REF_SCRIPT_USERNAME )
{
struct passwd * pw = getpwuid( st.st_uid );
if ( pw )
return snprintf( pValue, bufLen, "%s", pw->pw_name );
}
else
{
struct group * gr = getgrgid( st.st_gid );
if ( gr )
return snprintf( pValue, bufLen, "%s", gr->gr_name );
}
}
return 0;
}
case REF_PATH_INFO:
//.........这里部分代码省略.........