예제 #1
0
Dictionary::Ptr HttpUtility::FetchRequestParameters(HttpRequest& request)
{
	Dictionary::Ptr result;

	String body;
	char buffer[1024];
	size_t count;

	while ((count = request.ReadBody(buffer, sizeof(buffer))) > 0)
		body += String(buffer, buffer + count);

	if (!body.IsEmpty()) {
#ifdef I2_DEBUG
		Log(LogDebug, "HttpUtility")
		    << "Request body: '" << body << "'";
#endif /* I2_DEBUG */
		result = JsonDecode(body);
	}

	if (!result)
		result = new Dictionary();

	typedef std::pair<String, std::vector<String> > kv_pair;
	for (const kv_pair& kv : request.RequestUrl->GetQuery()) {
		result->Set(kv.first, Array::FromVector(kv.second));
	}

	return result;
}
예제 #2
0
Dictionary::Ptr HttpUtility::FetchRequestParameters(HttpRequest& request)
{
	Dictionary::Ptr result;

	String body;
	char buffer[1024];
	size_t count;

	while ((count = request.ReadBody(buffer, sizeof(buffer))) > 0)
		body += String(buffer, buffer + count);

	if (!body.IsEmpty())
		result = JsonDecode(body);

	if (!result)
		result = new Dictionary();

	typedef std::pair<String, std::vector<String> > kv_pair;
	BOOST_FOREACH(const kv_pair& kv, request.RequestUrl->GetQuery()) {
		result->Set(kv.first, Array::FromVector(kv.second));
	}

	return result;
}