Split vhost from *app in forms of "APP?vhost=..." and overwrite *host.
| 2780 | |
| 2781 | // Split vhost from *app in forms of "APP?vhost=..." and overwrite *host. |
| 2782 | static void SplitVHostFromApp(const butil::StringPiece& app_and_vhost, |
| 2783 | butil::StringPiece* app, |
| 2784 | butil::StringPiece* vhost) { |
| 2785 | const size_t q_pos = app_and_vhost.find('?'); |
| 2786 | if (q_pos == butil::StringPiece::npos) { |
| 2787 | if (app) { |
| 2788 | *app = app_and_vhost; |
| 2789 | } |
| 2790 | if (vhost) { |
| 2791 | vhost->clear(); |
| 2792 | } |
| 2793 | return; |
| 2794 | } |
| 2795 | |
| 2796 | if (app) { |
| 2797 | *app = app_and_vhost.substr(0, q_pos); |
| 2798 | } |
| 2799 | if (vhost) { |
| 2800 | butil::StringPiece qstr = app_and_vhost.substr(q_pos + 1); |
| 2801 | butil::StringSplitter sp(qstr.data(), qstr.data() + qstr.size(), '&'); |
| 2802 | for (; sp; ++sp) { |
| 2803 | butil::StringPiece field(sp.field(), sp.length()); |
| 2804 | if (field.starts_with("vhost=")) { |
| 2805 | *vhost = field.substr(6); |
| 2806 | // vhost cannot have port. |
| 2807 | const size_t colon_pos = vhost->find_last_of(':'); |
| 2808 | if (colon_pos != butil::StringPiece::npos) { |
| 2809 | vhost->remove_suffix(vhost->size() - colon_pos); |
| 2810 | } |
| 2811 | return; |
| 2812 | } |
| 2813 | } |
| 2814 | vhost->clear(); |
| 2815 | } |
| 2816 | } |
| 2817 | |
| 2818 | void ParseRtmpURL(const butil::StringPiece& rtmp_url_in, |
| 2819 | butil::StringPiece* host, |
no test coverage detected