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


C++ HTTPRequest::getContentType方法代码示例

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


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

示例1: load

void HTMLForm::load(const HTTPRequest& request, std::istream& requestBody, PartHandler& handler)
{
	if (request.getMethod() == HTTPRequest::HTTP_POST)
	{
		std::string mediaType;
		NameValueCollection params;
		MessageHeader::splitParameters(request.getContentType(), mediaType, params); 
		_encoding = mediaType;
		if (_encoding == ENCODING_MULTIPART)
		{
			_boundary = params["boundary"];
			readMultipart(requestBody, handler);
		}
		else
		{
			readUrl(requestBody);
		}
	}
	else
	{
		URI uri(request.getURI());
		std::istringstream istr(uri.getRawQuery());
		readUrl(istr);
	}
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例2: parse

CGIParser::CGIParser(const HTTPRequest& request, bool queryOnly)
{
    parse(request.getQueryString());
    if (!queryOnly && !strcmp(request.getMethod(),"POST")) {
        if (request.getContentType().find("application/x-www-form-urlencoded") != string::npos)
            parse(request.getRequestBody());
    }
}
开发者ID:svn2github,项目名称:cpp-sp,代码行数:8,代码来源:CGIParser.cpp

示例3: s

void HTTPRequestTest::testRead4()
{
	std::string s("POST /test.cgi HTTP/1.1\r\nConnection: Close\r\nContent-Length:   100  \r\nContent-Type: text/plain\r\nHost: localhost:8000\r\nUser-Agent: Poco\r\n\r\n");
	std::istringstream istr(s);
	HTTPRequest request;
	request.read(istr);
	assert (request.getMethod() == HTTPRequest::HTTP_POST);
	assert (request.getURI() == "/test.cgi");
	assert (request.getVersion() == HTTPMessage::HTTP_1_1);
	assert (request.size() == 5);
	assert (request["Connection"] == "Close");
	assert (request["Host"] == "localhost:8000");
	assert (request["User-Agent"] == "Poco");
	assert (request.getContentType() == "text/plain");
	assert (request.getContentLength() == 100);
	assert (istr.get() == -1);
}
开发者ID:macchina-io,项目名称:macchina.io,代码行数:17,代码来源:HTTPRequestTest.cpp


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