winlin

implements the http stream module.

@@ -85,53 +85,21 @@ bool SrsHttpRoot::can_handle(const char* path, int length, const char** pchild) @@ -85,53 +85,21 @@ bool SrsHttpRoot::can_handle(const char* path, int length, const char** pchild)
85 // for child to reparse the path. 85 // for child to reparse the path.
86 *pchild = path; 86 *pchild = path;
87 87
88 - // only compare the first char.  
89 - return srs_path_equals("/", path, 1); 88 + // never handle request for root.
  89 + return false;
90 } 90 }
91 91
92 bool SrsHttpRoot::is_handler_valid(SrsHttpMessage* req, int& status_code, std::string& reason_phrase) 92 bool SrsHttpRoot::is_handler_valid(SrsHttpMessage* req, int& status_code, std::string& reason_phrase)
93 { 93 {
94 - if (!SrsHttpHandler::is_handler_valid(req, status_code, reason_phrase)) {  
95 - return false;  
96 - }  
97 -  
98 - if (req->match()->matched_url.length() != 1) {  
99 - status_code = HTTP_NotFound;  
100 - reason_phrase = HTTP_NotFound_str; 94 + status_code = HTTP_InternalServerError;
  95 + reason_phrase = HTTP_InternalServerError_str;
101 return false; 96 return false;
102 - }  
103 -  
104 - return true;  
105 } 97 }
106 98
107 int SrsHttpRoot::do_process_request(SrsSocket* skt, SrsHttpMessage* req) 99 int SrsHttpRoot::do_process_request(SrsSocket* skt, SrsHttpMessage* req)
108 { 100 {
109 - std::stringstream ss;  
110 -  
111 - ss << JOBJECT_START  
112 - << JFIELD_ERROR(ERROR_SUCCESS) << JFIELD_CONT  
113 - << JFIELD_ORG("urls", JOBJECT_START);  
114 -  
115 - vector<SrsHttpHandler*>::iterator it;  
116 - for (it = handlers.begin(); it != handlers.end(); ++it) {  
117 - SrsHttpVhost* handler = dynamic_cast<SrsHttpVhost*>(*it);  
118 - srs_assert(handler);  
119 -  
120 - ss << JFIELD_ORG(handler->mount(), JOBJECT_START)  
121 - << JFIELD_STR("mount", handler->mount()) << JFIELD_CONT  
122 - << JFIELD_STR("vhost", handler->vhost()) << JFIELD_CONT  
123 - << JFIELD_STR("dir", handler->dir())  
124 - << JOBJECT_END;  
125 -  
126 - if (it + 1 != handlers.end()) {  
127 - ss << JFIELD_CONT;  
128 - }  
129 - }  
130 -  
131 - ss << JOBJECT_END  
132 - << JOBJECT_END;  
133 -  
134 - return res_json(skt, req, ss.str()); 101 + int ret = ERROR_SUCCESS;
  102 + return ret;
135 } 103 }
136 104
137 SrsHttpVhost::SrsHttpVhost(std::string vhost, std::string mount, std::string dir) 105 SrsHttpVhost::SrsHttpVhost(std::string vhost, std::string mount, std::string dir)