winlin

add favicon.ico, change to 0.9.65

@@ -365,6 +365,10 @@ ln -sf `pwd`/research/players ${SRS_OBJS}/nginx/html/players && @@ -365,6 +365,10 @@ ln -sf `pwd`/research/players ${SRS_OBJS}/nginx/html/players &&
365 rm -f ${SRS_OBJS}/nginx/crossdomain.xml && 365 rm -f ${SRS_OBJS}/nginx/crossdomain.xml &&
366 ln -sf `pwd`/research/players/crossdomain.xml ${SRS_OBJS}/nginx/html/crossdomain.xml 366 ln -sf `pwd`/research/players/crossdomain.xml ${SRS_OBJS}/nginx/html/crossdomain.xml
367 367
  368 +# for favicon.ico
  369 +rm -rf ${SRS_OBJS}/nginx/html/favicon.ico &&
  370 +ln -sf `pwd`/research/api-server/static-dir/favicon.ico ${SRS_OBJS}/nginx/html/favicon.ico
  371 +
368 # nginx.html to detect whether nginx is alive 372 # nginx.html to detect whether nginx is alive
369 echo "nginx is ok" > ${SRS_OBJS}/nginx/html/nginx.html 373 echo "nginx is ok" > ${SRS_OBJS}/nginx/html/nginx.html
370 374
@@ -116,7 +116,7 @@ int SrsHttpHandler::process_request(SrsSocket* skt, SrsHttpMessage* req) @@ -116,7 +116,7 @@ int SrsHttpHandler::process_request(SrsSocket* skt, SrsHttpMessage* req)
116 return do_process_request(skt, req); 116 return do_process_request(skt, req);
117 } 117 }
118 118
119 -bool SrsHttpHandler::is_handler_valid(SrsHttpMessage* req, int& status_code, std::string& reason_phrase) 119 +bool SrsHttpHandler::is_handler_valid(SrsHttpMessage* req, int& status_code, string& reason_phrase)
120 { 120 {
121 if (!req->match()->unmatched_url.empty()) { 121 if (!req->match()->unmatched_url.empty()) {
122 status_code = HTTP_NotFound; 122 status_code = HTTP_NotFound;
@@ -203,83 +203,90 @@ int SrsHttpHandler::best_match(const char* path, int length, SrsHttpHandlerMatch @@ -203,83 +203,90 @@ int SrsHttpHandler::best_match(const char* path, int length, SrsHttpHandlerMatch
203 return ret; 203 return ret;
204 } 204 }
205 205
206 -SrsHttpHandler* SrsHttpHandler::res_status_line(std::stringstream& ss) 206 +SrsHttpHandler* SrsHttpHandler::res_status_line(stringstream& ss)
207 { 207 {
208 ss << "HTTP/1.1 200 OK " << __CRLF 208 ss << "HTTP/1.1 200 OK " << __CRLF
209 << "Server: SRS/"RTMP_SIG_SRS_VERSION"" << __CRLF; 209 << "Server: SRS/"RTMP_SIG_SRS_VERSION"" << __CRLF;
210 return this; 210 return this;
211 } 211 }
212 212
213 -SrsHttpHandler* SrsHttpHandler::res_status_line_error(std::stringstream& ss, int code, std::string reason_phrase) 213 +SrsHttpHandler* SrsHttpHandler::res_status_line_error(stringstream& ss, int code, string reason_phrase)
214 { 214 {
215 ss << "HTTP/1.1 " << code << " " << reason_phrase << __CRLF 215 ss << "HTTP/1.1 " << code << " " << reason_phrase << __CRLF
216 << "Server: SRS/"RTMP_SIG_SRS_VERSION"" << __CRLF; 216 << "Server: SRS/"RTMP_SIG_SRS_VERSION"" << __CRLF;
217 return this; 217 return this;
218 } 218 }
219 219
220 -SrsHttpHandler* SrsHttpHandler::res_content_type(std::stringstream& ss) 220 +SrsHttpHandler* SrsHttpHandler::res_content_type(stringstream& ss)
221 { 221 {
222 ss << "Content-Type: text/html;charset=utf-8" << __CRLF 222 ss << "Content-Type: text/html;charset=utf-8" << __CRLF
223 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 223 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
224 return this; 224 return this;
225 } 225 }
226 226
227 -SrsHttpHandler* SrsHttpHandler::res_content_type_xml(std::stringstream& ss) 227 +SrsHttpHandler* SrsHttpHandler::res_content_type_xml(stringstream& ss)
228 { 228 {
229 ss << "Content-Type: text/xml;charset=utf-8" << __CRLF 229 ss << "Content-Type: text/xml;charset=utf-8" << __CRLF
230 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 230 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
231 return this; 231 return this;
232 } 232 }
233 233
234 -SrsHttpHandler* SrsHttpHandler::res_content_type_javascript(std::stringstream& ss) 234 +SrsHttpHandler* SrsHttpHandler::res_content_type_javascript(stringstream& ss)
235 { 235 {
236 - ss << "Content-Type: text/javascript;charset=utf-8" << __CRLF 236 + ss << "Content-Type: text/javascript" << __CRLF
237 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 237 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
238 return this; 238 return this;
239 } 239 }
240 240
241 -SrsHttpHandler* SrsHttpHandler::res_content_type_swf(std::stringstream& ss) 241 +SrsHttpHandler* SrsHttpHandler::res_content_type_swf(stringstream& ss)
242 { 242 {
243 - ss << "Content-Type: application/x-shockwave-flash;charset=utf-8" << __CRLF 243 + ss << "Content-Type: application/x-shockwave-flash" << __CRLF
244 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 244 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
245 return this; 245 return this;
246 } 246 }
247 247
248 -SrsHttpHandler* SrsHttpHandler::res_content_type_css(std::stringstream& ss) 248 +SrsHttpHandler* SrsHttpHandler::res_content_type_css(stringstream& ss)
249 { 249 {
250 ss << "Content-Type: text/css;charset=utf-8" << __CRLF 250 ss << "Content-Type: text/css;charset=utf-8" << __CRLF
251 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 251 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
252 return this; 252 return this;
253 } 253 }
254 254
255 -SrsHttpHandler* SrsHttpHandler::res_content_type_json(std::stringstream& ss) 255 +SrsHttpHandler* SrsHttpHandler::res_content_type_ico(stringstream& ss)
  256 +{
  257 + ss << "Content-Type: image/x-icon" << __CRLF
  258 + << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
  259 + return this;
  260 +}
  261 +
  262 +SrsHttpHandler* SrsHttpHandler::res_content_type_json(stringstream& ss)
256 { 263 {
257 ss << "Content-Type: application/json;charset=utf-8" << __CRLF 264 ss << "Content-Type: application/json;charset=utf-8" << __CRLF
258 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 265 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
259 return this; 266 return this;
260 } 267 }
261 268
262 -SrsHttpHandler* SrsHttpHandler::res_content_type_m3u8(std::stringstream& ss) 269 +SrsHttpHandler* SrsHttpHandler::res_content_type_m3u8(stringstream& ss)
263 { 270 {
264 ss << "Content-Type: application/x-mpegURL;charset=utf-8" << __CRLF 271 ss << "Content-Type: application/x-mpegURL;charset=utf-8" << __CRLF
265 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 272 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
266 return this; 273 return this;
267 } 274 }
268 275
269 -SrsHttpHandler* SrsHttpHandler::res_content_type_mpegts(std::stringstream& ss) 276 +SrsHttpHandler* SrsHttpHandler::res_content_type_mpegts(stringstream& ss)
270 { 277 {
271 - ss << "Content-Type: video/MP2T;charset=utf-8" << __CRLF 278 + ss << "Content-Type: video/MP2T" << __CRLF
272 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; 279 << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF;
273 return this; 280 return this;
274 } 281 }
275 282
276 -SrsHttpHandler* SrsHttpHandler::res_content_length(std::stringstream& ss, int64_t length) 283 +SrsHttpHandler* SrsHttpHandler::res_content_length(stringstream& ss, int64_t length)
277 { 284 {
278 ss << "Content-Length: "<< length << __CRLF; 285 ss << "Content-Length: "<< length << __CRLF;
279 return this; 286 return this;
280 } 287 }
281 288
282 -SrsHttpHandler* SrsHttpHandler::res_enable_crossdomain(std::stringstream& ss) 289 +SrsHttpHandler* SrsHttpHandler::res_enable_crossdomain(stringstream& ss)
283 { 290 {
284 ss << "Access-Control-Allow-Origin: *" << __CRLF 291 ss << "Access-Control-Allow-Origin: *" << __CRLF
285 << "Access-Control-Allow-Methods: " 292 << "Access-Control-Allow-Methods: "
@@ -289,19 +296,19 @@ SrsHttpHandler* SrsHttpHandler::res_enable_crossdomain(std::stringstream& ss) @@ -289,19 +296,19 @@ SrsHttpHandler* SrsHttpHandler::res_enable_crossdomain(std::stringstream& ss)
289 return this; 296 return this;
290 } 297 }
291 298
292 -SrsHttpHandler* SrsHttpHandler::res_header_eof(std::stringstream& ss) 299 +SrsHttpHandler* SrsHttpHandler::res_header_eof(stringstream& ss)
293 { 300 {
294 ss << __CRLF; 301 ss << __CRLF;
295 return this; 302 return this;
296 } 303 }
297 304
298 -SrsHttpHandler* SrsHttpHandler::res_body(std::stringstream& ss, std::string body) 305 +SrsHttpHandler* SrsHttpHandler::res_body(stringstream& ss, string body)
299 { 306 {
300 ss << body; 307 ss << body;
301 return this; 308 return this;
302 } 309 }
303 310
304 -int SrsHttpHandler::res_flush(SrsSocket* skt, std::stringstream& ss) 311 +int SrsHttpHandler::res_flush(SrsSocket* skt, stringstream& ss)
305 { 312 {
306 return skt->write(ss.str().c_str(), ss.str().length(), NULL); 313 return skt->write(ss.str().c_str(), ss.str().length(), NULL);
307 } 314 }
@@ -317,7 +324,7 @@ int SrsHttpHandler::res_options(SrsSocket* skt) @@ -317,7 +324,7 @@ int SrsHttpHandler::res_options(SrsSocket* skt)
317 return res_flush(skt, ss); 324 return res_flush(skt, ss);
318 } 325 }
319 326
320 -int SrsHttpHandler::res_text(SrsSocket* skt, SrsHttpMessage* req, std::string body) 327 +int SrsHttpHandler::res_text(SrsSocket* skt, SrsHttpMessage* req, string body)
321 { 328 {
322 std::stringstream ss; 329 std::stringstream ss;
323 330
@@ -334,7 +341,7 @@ int SrsHttpHandler::res_text(SrsSocket* skt, SrsHttpMessage* req, std::string bo @@ -334,7 +341,7 @@ int SrsHttpHandler::res_text(SrsSocket* skt, SrsHttpMessage* req, std::string bo
334 return res_flush(skt, ss); 341 return res_flush(skt, ss);
335 } 342 }
336 343
337 -int SrsHttpHandler::res_xml(SrsSocket* skt, SrsHttpMessage* req, std::string body) 344 +int SrsHttpHandler::res_xml(SrsSocket* skt, SrsHttpMessage* req, string body)
338 { 345 {
339 std::stringstream ss; 346 std::stringstream ss;
340 347
@@ -351,7 +358,7 @@ int SrsHttpHandler::res_xml(SrsSocket* skt, SrsHttpMessage* req, std::string bod @@ -351,7 +358,7 @@ int SrsHttpHandler::res_xml(SrsSocket* skt, SrsHttpMessage* req, std::string bod
351 return res_flush(skt, ss); 358 return res_flush(skt, ss);
352 } 359 }
353 360
354 -int SrsHttpHandler::res_javascript(SrsSocket* skt, SrsHttpMessage* req, std::string body) 361 +int SrsHttpHandler::res_javascript(SrsSocket* skt, SrsHttpMessage* req, string body)
355 { 362 {
356 std::stringstream ss; 363 std::stringstream ss;
357 364
@@ -368,7 +375,7 @@ int SrsHttpHandler::res_javascript(SrsSocket* skt, SrsHttpMessage* req, std::str @@ -368,7 +375,7 @@ int SrsHttpHandler::res_javascript(SrsSocket* skt, SrsHttpMessage* req, std::str
368 return res_flush(skt, ss); 375 return res_flush(skt, ss);
369 } 376 }
370 377
371 -int SrsHttpHandler::res_swf(SrsSocket* skt, SrsHttpMessage* req, std::string body) 378 +int SrsHttpHandler::res_swf(SrsSocket* skt, SrsHttpMessage* req, string body)
372 { 379 {
373 std::stringstream ss; 380 std::stringstream ss;
374 381
@@ -385,7 +392,7 @@ int SrsHttpHandler::res_swf(SrsSocket* skt, SrsHttpMessage* req, std::string bod @@ -385,7 +392,7 @@ int SrsHttpHandler::res_swf(SrsSocket* skt, SrsHttpMessage* req, std::string bod
385 return res_flush(skt, ss); 392 return res_flush(skt, ss);
386 } 393 }
387 394
388 -int SrsHttpHandler::res_css(SrsSocket* skt, SrsHttpMessage* req, std::string body) 395 +int SrsHttpHandler::res_css(SrsSocket* skt, SrsHttpMessage* req, string body)
389 { 396 {
390 std::stringstream ss; 397 std::stringstream ss;
391 398
@@ -402,7 +409,24 @@ int SrsHttpHandler::res_css(SrsSocket* skt, SrsHttpMessage* req, std::string bod @@ -402,7 +409,24 @@ int SrsHttpHandler::res_css(SrsSocket* skt, SrsHttpMessage* req, std::string bod
402 return res_flush(skt, ss); 409 return res_flush(skt, ss);
403 } 410 }
404 411
405 -int SrsHttpHandler::res_m3u8(SrsSocket* skt, SrsHttpMessage* req, std::string body) 412 +int SrsHttpHandler::res_ico(SrsSocket* skt, SrsHttpMessage* req, string body)
  413 +{
  414 + std::stringstream ss;
  415 +
  416 + res_status_line(ss)->res_content_type_ico(ss)
  417 + ->res_content_length(ss, (int)body.length());
  418 +
  419 + if (req->requires_crossdomain()) {
  420 + res_enable_crossdomain(ss);
  421 + }
  422 +
  423 + res_header_eof(ss)
  424 + ->res_body(ss, body);
  425 +
  426 + return res_flush(skt, ss);
  427 +}
  428 +
  429 +int SrsHttpHandler::res_m3u8(SrsSocket* skt, SrsHttpMessage* req, string body)
406 { 430 {
407 std::stringstream ss; 431 std::stringstream ss;
408 432
@@ -419,7 +443,7 @@ int SrsHttpHandler::res_m3u8(SrsSocket* skt, SrsHttpMessage* req, std::string bo @@ -419,7 +443,7 @@ int SrsHttpHandler::res_m3u8(SrsSocket* skt, SrsHttpMessage* req, std::string bo
419 return res_flush(skt, ss); 443 return res_flush(skt, ss);
420 } 444 }
421 445
422 -int SrsHttpHandler::res_mpegts(SrsSocket* skt, SrsHttpMessage* req, std::string body) 446 +int SrsHttpHandler::res_mpegts(SrsSocket* skt, SrsHttpMessage* req, string body)
423 { 447 {
424 std::stringstream ss; 448 std::stringstream ss;
425 449
@@ -436,7 +460,7 @@ int SrsHttpHandler::res_mpegts(SrsSocket* skt, SrsHttpMessage* req, std::string @@ -436,7 +460,7 @@ int SrsHttpHandler::res_mpegts(SrsSocket* skt, SrsHttpMessage* req, std::string
436 return res_flush(skt, ss); 460 return res_flush(skt, ss);
437 } 461 }
438 462
439 -int SrsHttpHandler::res_json(SrsSocket* skt, SrsHttpMessage* req, std::string json) 463 +int SrsHttpHandler::res_json(SrsSocket* skt, SrsHttpMessage* req, string json)
440 { 464 {
441 std::stringstream ss; 465 std::stringstream ss;
442 466
@@ -453,7 +477,7 @@ int SrsHttpHandler::res_json(SrsSocket* skt, SrsHttpMessage* req, std::string js @@ -453,7 +477,7 @@ int SrsHttpHandler::res_json(SrsSocket* skt, SrsHttpMessage* req, std::string js
453 return res_flush(skt, ss); 477 return res_flush(skt, ss);
454 } 478 }
455 479
456 -int SrsHttpHandler::res_error(SrsSocket* skt, SrsHttpMessage* req, int code, std::string reason_phrase, std::string body) 480 +int SrsHttpHandler::res_error(SrsSocket* skt, SrsHttpMessage* req, int code, string reason_phrase, string body)
457 { 481 {
458 std::stringstream ss; 482 std::stringstream ss;
459 483
@@ -577,7 +601,7 @@ bool SrsHttpMessage::requires_crossdomain() @@ -577,7 +601,7 @@ bool SrsHttpMessage::requires_crossdomain()
577 return _requires_crossdomain; 601 return _requires_crossdomain;
578 } 602 }
579 603
580 -void SrsHttpMessage::set_url(std::string url) 604 +void SrsHttpMessage::set_url(string url)
581 { 605 {
582 _url = url; 606 _url = url;
583 } 607 }
@@ -789,7 +813,7 @@ SrsHttpUri::~SrsHttpUri() @@ -789,7 +813,7 @@ SrsHttpUri::~SrsHttpUri()
789 { 813 {
790 } 814 }
791 815
792 -int SrsHttpUri::initialize(std::string _url) 816 +int SrsHttpUri::initialize(string _url)
793 { 817 {
794 int ret = ERROR_SUCCESS; 818 int ret = ERROR_SUCCESS;
795 819
@@ -856,7 +880,7 @@ const char* SrsHttpUri::get_query() @@ -856,7 +880,7 @@ const char* SrsHttpUri::get_query()
856 return path.data(); 880 return path.data();
857 } 881 }
858 882
859 -std::string SrsHttpUri::get_uri_field(std::string uri, http_parser_url* hp_u, http_parser_url_fields field) 883 +string SrsHttpUri::get_uri_field(string uri, http_parser_url* hp_u, http_parser_url_fields field)
860 { 884 {
861 if((hp_u->field_set & (1 << field)) == 0){ 885 if((hp_u->field_set & (1 << field)) == 0){
862 return ""; 886 return "";
@@ -237,6 +237,7 @@ public: @@ -237,6 +237,7 @@ public:
237 virtual SrsHttpHandler* res_content_type_javascript(std::stringstream& ss); 237 virtual SrsHttpHandler* res_content_type_javascript(std::stringstream& ss);
238 virtual SrsHttpHandler* res_content_type_swf(std::stringstream& ss); 238 virtual SrsHttpHandler* res_content_type_swf(std::stringstream& ss);
239 virtual SrsHttpHandler* res_content_type_css(std::stringstream& ss); 239 virtual SrsHttpHandler* res_content_type_css(std::stringstream& ss);
  240 + virtual SrsHttpHandler* res_content_type_ico(std::stringstream& ss);
240 virtual SrsHttpHandler* res_content_type_json(std::stringstream& ss); 241 virtual SrsHttpHandler* res_content_type_json(std::stringstream& ss);
241 virtual SrsHttpHandler* res_content_type_m3u8(std::stringstream& ss); 242 virtual SrsHttpHandler* res_content_type_m3u8(std::stringstream& ss);
242 virtual SrsHttpHandler* res_content_type_mpegts(std::stringstream& ss); 243 virtual SrsHttpHandler* res_content_type_mpegts(std::stringstream& ss);
@@ -252,6 +253,7 @@ public: @@ -252,6 +253,7 @@ public:
252 virtual int res_javascript(SrsSocket* skt, SrsHttpMessage* req, std::string body); 253 virtual int res_javascript(SrsSocket* skt, SrsHttpMessage* req, std::string body);
253 virtual int res_swf(SrsSocket* skt, SrsHttpMessage* req, std::string body); 254 virtual int res_swf(SrsSocket* skt, SrsHttpMessage* req, std::string body);
254 virtual int res_css(SrsSocket* skt, SrsHttpMessage* req, std::string body); 255 virtual int res_css(SrsSocket* skt, SrsHttpMessage* req, std::string body);
  256 + virtual int res_ico(SrsSocket* skt, SrsHttpMessage* req, std::string body);
255 virtual int res_m3u8(SrsSocket* skt, SrsHttpMessage* req, std::string body); 257 virtual int res_m3u8(SrsSocket* skt, SrsHttpMessage* req, std::string body);
256 virtual int res_mpegts(SrsSocket* skt, SrsHttpMessage* req, std::string body); 258 virtual int res_mpegts(SrsSocket* skt, SrsHttpMessage* req, std::string body);
257 virtual int res_json(SrsSocket* skt, SrsHttpMessage* req, std::string json); 259 virtual int res_json(SrsSocket* skt, SrsHttpMessage* req, std::string json);
@@ -202,6 +202,8 @@ int SrsHttpVhost::do_process_request(SrsSocket* skt, SrsHttpMessage* req) @@ -202,6 +202,8 @@ int SrsHttpVhost::do_process_request(SrsSocket* skt, SrsHttpMessage* req)
202 return res_swf(skt, req, str); 202 return res_swf(skt, req, str);
203 } else if (srs_string_ends_with(fullpath, ".css")) { 203 } else if (srs_string_ends_with(fullpath, ".css")) {
204 return res_css(skt, req, str); 204 return res_css(skt, req, str);
  205 + } else if (srs_string_ends_with(fullpath, ".ico")) {
  206 + return res_ico(skt, req, str);
205 } else { 207 } else {
206 return res_text(skt, req, str); 208 return res_text(skt, req, str);
207 } 209 }
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR "0" 32 #define VERSION_MAJOR "0"
33 #define VERSION_MINOR "9" 33 #define VERSION_MINOR "9"
34 -#define VERSION_REVISION "64" 34 +#define VERSION_REVISION "65"
35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION 35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "srs" 37 #define RTMP_SIG_SRS_KEY "srs"