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; }
BufferRef HttpRequest::requestHeader(const std::string& name) const { for (auto& i: requestHeaders) if (iequals(i.name, name)) return i.value; return BufferRef(); }
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(); }
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(); } } } }
BufferRef BufferPool::getEmptyBuffer() { return BufferRef(new EmptyBuffer(1, 44100)); // TODO }
BufferRef BufferPool::getNewBuffer(t_audoNSamples size) { t_audoSample sampleRate = 44100; // TODO StandardBuffer *buffer = new StandardBuffer(size, sampleRate, ""); return BufferRef(buffer); }
std::unique_ptr<Vary> Vary::create(const x0::HttpRequest* r) { return create(BufferRef(r->responseHeaders["Vary"]), r->requestHeaders); }