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


C++ cHTTPRequest::GetContentType方法代码示例

本文整理汇总了C++中cHTTPRequest::GetContentType方法的典型用法代码示例。如果您正苦于以下问题:C++ cHTTPRequest::GetContentType方法的具体用法?C++ cHTTPRequest::GetContentType怎么用?C++ cHTTPRequest::GetContentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cHTTPRequest的用法示例。


在下文中一共展示了cHTTPRequest::GetContentType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

cHTTPFormParser::cHTTPFormParser(cHTTPRequest & a_Request, cCallbacks & a_Callbacks) :
	m_Callbacks(a_Callbacks),
	m_IsValid(true)
{
	if (a_Request.GetMethod() == "GET")
	{
		m_Kind = fpkURL;
		
		// Directly parse the URL in the request:
		const AString & URL = a_Request.GetURL();
		size_t idxQM = URL.find('?');
		if (idxQM != AString::npos)
		{
			Parse(URL.c_str() + idxQM + 1, URL.size() - idxQM - 1);
		}
		return;
	}
	if ((a_Request.GetMethod() == "POST") || (a_Request.GetMethod() == "PUT"))
	{
		if (strncmp(a_Request.GetContentType().c_str(), "application/x-www-form-urlencoded", 33) == 0)
		{
			m_Kind = fpkFormUrlEncoded;
			return;
		}
		if (strncmp(a_Request.GetContentType().c_str(), "multipart/form-data", 19) == 0)
		{
			m_Kind = fpkMultipart;
			BeginMultipart(a_Request);
			return;
		}
	}
	// Invalid method / content type combination, this is not a HTTP form
	m_IsValid = false;
}
开发者ID:JoeClacks,项目名称:MCServer,代码行数:34,代码来源:HTTPFormParser.cpp

示例2: HasFormData

bool cHTTPFormParser::HasFormData(const cHTTPRequest & a_Request)
{
	const AString & ContentType = a_Request.GetContentType();
	return (
		(ContentType == "application/x-www-form-urlencoded") ||
		(strncmp(ContentType.c_str(), "multipart/form-data", 19) == 0) ||
		(
			(a_Request.GetMethod() == "GET") &&
			(a_Request.GetURL().find('?') != AString::npos)
		)
	);
}
开发者ID:36451,项目名称:MCServer,代码行数:12,代码来源:HTTPFormParser.cpp

示例3: BeginMultipart

void cHTTPFormParser::BeginMultipart(const cHTTPRequest & a_Request)
{
	ASSERT(m_MultipartParser.get() == nullptr);
	m_MultipartParser.reset(new cMultipartParser(a_Request.GetContentType(), *this));
}
开发者ID:36451,项目名称:MCServer,代码行数:5,代码来源:HTTPFormParser.cpp


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