正在显示
5 个修改的文件
包含
34 行增加
和
6 行删除
| @@ -584,6 +584,27 @@ u_int8_t SrsHttpMessage::method() | @@ -584,6 +584,27 @@ u_int8_t SrsHttpMessage::method() | ||
| 584 | return (u_int8_t)_header.method; | 584 | return (u_int8_t)_header.method; |
| 585 | } | 585 | } |
| 586 | 586 | ||
| 587 | +string SrsHttpMessage::method_str() | ||
| 588 | +{ | ||
| 589 | + if (is_http_get()) { | ||
| 590 | + return "GET"; | ||
| 591 | + } | ||
| 592 | + if (is_http_put()) { | ||
| 593 | + return "PUT"; | ||
| 594 | + } | ||
| 595 | + if (is_http_post()) { | ||
| 596 | + return "POST"; | ||
| 597 | + } | ||
| 598 | + if (is_http_delete()) { | ||
| 599 | + return "DELETE"; | ||
| 600 | + } | ||
| 601 | + if (is_http_options()) { | ||
| 602 | + return "OPTIONS"; | ||
| 603 | + } | ||
| 604 | + | ||
| 605 | + return "OTHER"; | ||
| 606 | +} | ||
| 607 | + | ||
| 587 | bool SrsHttpMessage::is_http_get() | 608 | bool SrsHttpMessage::is_http_get() |
| 588 | { | 609 | { |
| 589 | return _header.method == HTTP_GET; | 610 | return _header.method == HTTP_GET; |
| @@ -604,6 +625,11 @@ bool SrsHttpMessage::is_http_delete() | @@ -604,6 +625,11 @@ bool SrsHttpMessage::is_http_delete() | ||
| 604 | return _header.method == HTTP_DELETE; | 625 | return _header.method == HTTP_DELETE; |
| 605 | } | 626 | } |
| 606 | 627 | ||
| 628 | +bool SrsHttpMessage::is_http_options() | ||
| 629 | +{ | ||
| 630 | + return _header.method == HTTP_OPTIONS; | ||
| 631 | +} | ||
| 632 | + | ||
| 607 | string SrsHttpMessage::uri() | 633 | string SrsHttpMessage::uri() |
| 608 | { | 634 | { |
| 609 | std::string uri = _uri->get_schema(); | 635 | std::string uri = _uri->get_schema(); |
| @@ -337,10 +337,12 @@ public: | @@ -337,10 +337,12 @@ public: | ||
| 337 | public: | 337 | public: |
| 338 | virtual bool is_complete(); | 338 | virtual bool is_complete(); |
| 339 | virtual u_int8_t method(); | 339 | virtual u_int8_t method(); |
| 340 | + virtual std::string method_str(); | ||
| 340 | virtual bool is_http_get(); | 341 | virtual bool is_http_get(); |
| 341 | virtual bool is_http_put(); | 342 | virtual bool is_http_put(); |
| 342 | virtual bool is_http_post(); | 343 | virtual bool is_http_post(); |
| 343 | virtual bool is_http_delete(); | 344 | virtual bool is_http_delete(); |
| 345 | + virtual bool is_http_options(); | ||
| 344 | virtual std::string uri(); | 346 | virtual std::string uri(); |
| 345 | virtual std::string url(); | 347 | virtual std::string url(); |
| 346 | virtual std::string host(); | 348 | virtual std::string host(); |
| @@ -731,8 +731,8 @@ int SrsHttpApi::process_request(SrsSocket* skt, SrsHttpMessage* req) | @@ -731,8 +731,8 @@ int SrsHttpApi::process_request(SrsSocket* skt, SrsHttpMessage* req) | ||
| 731 | return ret; | 731 | return ret; |
| 732 | } | 732 | } |
| 733 | 733 | ||
| 734 | - srs_trace("http request parsed, method=%d, url=%s, content-length=%"PRId64"", | ||
| 735 | - req->method(), req->url().c_str(), req->content_length()); | 734 | + srs_trace("HTTP %s %s, content-length=%"PRId64"", |
| 735 | + req->method_str().c_str(), req->url().c_str(), req->content_length()); | ||
| 736 | 736 | ||
| 737 | // TODO: maybe need to parse the url. | 737 | // TODO: maybe need to parse the url. |
| 738 | std::string url = req->path(); | 738 | std::string url = req->path(); |
| @@ -514,7 +514,7 @@ int SrsHttpConn::do_cycle() | @@ -514,7 +514,7 @@ int SrsHttpConn::do_cycle() | ||
| 514 | { | 514 | { |
| 515 | int ret = ERROR_SUCCESS; | 515 | int ret = ERROR_SUCCESS; |
| 516 | 516 | ||
| 517 | - srs_trace("http get peer ip success. ip=%s", ip.c_str()); | 517 | + srs_trace("HTTP client ip=%s", ip.c_str()); |
| 518 | 518 | ||
| 519 | // initialize parser | 519 | // initialize parser |
| 520 | if ((ret = parser->initialize(HTTP_REQUEST)) != ERROR_SUCCESS) { | 520 | if ((ret = parser->initialize(HTTP_REQUEST)) != ERROR_SUCCESS) { |
| @@ -559,8 +559,8 @@ int SrsHttpConn::process_request(SrsSocket* skt, SrsHttpMessage* req) | @@ -559,8 +559,8 @@ int SrsHttpConn::process_request(SrsSocket* skt, SrsHttpMessage* req) | ||
| 559 | return ret; | 559 | return ret; |
| 560 | } | 560 | } |
| 561 | 561 | ||
| 562 | - srs_trace("http request parsed, method=%d, url=%s, content-length=%"PRId64"", | ||
| 563 | - req->method(), req->url().c_str(), req->content_length()); | 562 | + srs_trace("HTTP %s %s, content-length=%"PRId64"", |
| 563 | + req->method_str().c_str(), req->url().c_str(), req->content_length()); | ||
| 564 | 564 | ||
| 565 | // TODO: maybe need to parse the url. | 565 | // TODO: maybe need to parse the url. |
| 566 | std::string url = req->path(); | 566 | std::string url = req->path(); |
| @@ -99,7 +99,7 @@ int SrsRtmpConn::do_cycle() | @@ -99,7 +99,7 @@ int SrsRtmpConn::do_cycle() | ||
| 99 | { | 99 | { |
| 100 | int ret = ERROR_SUCCESS; | 100 | int ret = ERROR_SUCCESS; |
| 101 | 101 | ||
| 102 | - srs_trace("serve client ip=%s", ip.c_str()); | 102 | + srs_trace("RTMP client ip=%s", ip.c_str()); |
| 103 | 103 | ||
| 104 | rtmp->set_recv_timeout(SRS_RECV_TIMEOUT_US); | 104 | rtmp->set_recv_timeout(SRS_RECV_TIMEOUT_US); |
| 105 | rtmp->set_send_timeout(SRS_SEND_TIMEOUT_US); | 105 | rtmp->set_send_timeout(SRS_SEND_TIMEOUT_US); |
-
请 注册 或 登录 后发表评论