예제 #1
0
bool HttpFileMgr::Settings::openMimeTypes(const std::string& path)
{
	Buffer input;
	if (!readFile(path, &input))
		return false;

	auto lines = Tokenizer<BufferRef, Buffer>::tokenize(input, "\n");

	mimetypes.clear();

	for (auto line: lines) {
		line = line.trim();
		auto columns = Tokenizer<BufferRef, BufferRef>::tokenize(line, " \t");

		auto ci = columns.begin(), ce = columns.end();
		BufferRef mime = ci != ce ? *ci++ : BufferRef();

		if (!mime.empty() && mime[0] != '#') {
			for (; ci != ce; ++ci) {
				mimetypes[ci->str()] = mime.str();
			}
		}
	}

	return true;
}
예제 #2
0
파일: HttpRequest.cpp 프로젝트: liveck/x0
BufferRef HttpRequest::requestHeader(const std::string& name) const
{
	for (auto& i: requestHeaders)
		if (iequals(i.name, name))
			return i.value;

	return BufferRef();
}
예제 #3
0
파일: HttpConnection.cpp 프로젝트: crnt/x0
bool HttpConnection::onMessageEnd()
{
	TRACE("onMessageEnd() %s (isHandlingRequest:%d)", status_str(), flags_ & IsHandlingRequest);

	// marks the request-content EOS, so that the application knows when the request body
	// has been fully passed to it.
	request_->onRequestContent(BufferRef());

	// If we are currently procesing a request, then stop parsing at the end of this request.
	// The next request, if available, is being processed via resume()
	if (flags_ & IsHandlingRequest)
		return false;

	return true; //shouldKeepAlive();
}
예제 #4
0
void FileInfoService::Config::loadMimetypes(const std::string& filename)
{
	Buffer input(x0::read_file(filename));
	auto lines = Tokenizer<BufferRef, Buffer>::tokenize(input, "\n");

	mimetypes.clear();

	for (auto line: lines) {
		line = line.trim();
		auto columns = Tokenizer<BufferRef, BufferRef>::tokenize(line, " \t");

		auto ci = columns.begin(), ce = columns.end();
		BufferRef mime = ci != ce ? *ci++ : BufferRef();

		if (!mime.empty() && mime[0] != '#') {
			for (; ci != ce; ++ci) {
				mimetypes[ci->str()] = mime.str();
			}
		}
	}
}
예제 #5
0
파일: BufferPool.cpp 프로젝트: d11/Audo
BufferRef BufferPool::getEmptyBuffer() {
   return BufferRef(new EmptyBuffer(1, 44100)); // TODO
}
예제 #6
0
파일: BufferPool.cpp 프로젝트: d11/Audo
BufferRef BufferPool::getNewBuffer(t_audoNSamples size) {
   t_audoSample sampleRate = 44100; // TODO
   StandardBuffer *buffer = new StandardBuffer(size, sampleRate, "");
   return BufferRef(buffer);
}
예제 #7
0
std::unique_ptr<Vary> Vary::create(const x0::HttpRequest* r)
{
	return create(BufferRef(r->responseHeaders["Vary"]), r->requestHeaders);
}