MCPcopy Create free account
hub / github.com/apache/brpc / SplitVHostFromApp

Function SplitVHostFromApp

src/brpc/rtmp.cpp:2782–2816  ·  view source on GitHub ↗

Split vhost from *app in forms of "APP?vhost=..." and overwrite *host.

Source from the content-addressed store, hash-verified

2780
2781// Split vhost from *app in forms of "APP?vhost=..." and overwrite *host.
2782static 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
2818void ParseRtmpURL(const butil::StringPiece& rtmp_url_in,
2819 butil::StringPiece* host,

Callers 1

ParseRtmpURLFunction · 0.85

Calls 10

substrMethod · 0.80
fieldMethod · 0.80
starts_withMethod · 0.80
find_last_ofMethod · 0.80
remove_suffixMethod · 0.80
findMethod · 0.45
clearMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected