implements the http stream module.

pull/133/head
winlin 11 years ago
parent 00eda0d7b2
commit ef26e77560

@ -85,53 +85,21 @@ bool SrsHttpRoot::can_handle(const char* path, int length, const char** pchild)
// for child to reparse the path. // for child to reparse the path.
*pchild = path; *pchild = path;
// only compare the first char. // never handle request for root.
return srs_path_equals("/", path, 1); return false;
} }
bool SrsHttpRoot::is_handler_valid(SrsHttpMessage* req, int& status_code, std::string& reason_phrase) bool SrsHttpRoot::is_handler_valid(SrsHttpMessage* req, int& status_code, std::string& reason_phrase)
{ {
if (!SrsHttpHandler::is_handler_valid(req, status_code, reason_phrase)) { status_code = HTTP_InternalServerError;
return false; reason_phrase = HTTP_InternalServerError_str;
}
if (req->match()->matched_url.length() != 1) {
status_code = HTTP_NotFound;
reason_phrase = HTTP_NotFound_str;
return false; return false;
} }
return true;
}
int SrsHttpRoot::do_process_request(SrsSocket* skt, SrsHttpMessage* req) int SrsHttpRoot::do_process_request(SrsSocket* skt, SrsHttpMessage* req)
{ {
std::stringstream ss; int ret = ERROR_SUCCESS;
return ret;
ss << JOBJECT_START
<< JFIELD_ERROR(ERROR_SUCCESS) << JFIELD_CONT
<< JFIELD_ORG("urls", JOBJECT_START);
vector<SrsHttpHandler*>::iterator it;
for (it = handlers.begin(); it != handlers.end(); ++it) {
SrsHttpVhost* handler = dynamic_cast<SrsHttpVhost*>(*it);
srs_assert(handler);
ss << JFIELD_ORG(handler->mount(), JOBJECT_START)
<< JFIELD_STR("mount", handler->mount()) << JFIELD_CONT
<< JFIELD_STR("vhost", handler->vhost()) << JFIELD_CONT
<< JFIELD_STR("dir", handler->dir())
<< JOBJECT_END;
if (it + 1 != handlers.end()) {
ss << JFIELD_CONT;
}
}
ss << JOBJECT_END
<< JOBJECT_END;
return res_json(skt, req, ss.str());
} }
SrsHttpVhost::SrsHttpVhost(std::string vhost, std::string mount, std::string dir) SrsHttpVhost::SrsHttpVhost(std::string vhost, std::string mount, std::string dir)

Loading…
Cancel
Save