Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2016-01-12 11:53:52 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f971538cf3162df5e76d43e7807d848dca9ccbf6
f971538c
1 parent
2941328e
refine http, support no host.
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
31 行增加
和
27 行删除
trunk/src/app/srs_app_http_conn.cpp
trunk/src/app/srs_app_utility.hpp
trunk/src/protocol/srs_protocol_utility.cpp
trunk/src/app/srs_app_http_conn.cpp
查看文件 @
f971538
...
...
@@ -58,6 +58,7 @@ using namespace std;
#include <srs_protocol_json.hpp>
#include <srs_app_http_hooks.hpp>
#include <srs_protocol_amf0.hpp>
#include <srs_app_utility.hpp>
#endif
...
...
@@ -541,11 +542,10 @@ int SrsHttpMessage::update(string url, bool allow_jsonp, http_parser* header, Sr
// parse uri from url.
std
::
string
host
=
get_request_header
(
"Host"
);
// donot parse the empty host for uri,
// for example, the response contains no host,
// ignore it is ok.
// use server public ip when no host specified.
// to make telnet happy.
if
(
host
.
empty
())
{
return
ret
;
host
=
srs_get_public_internet_address
()
;
}
// parse uri to schema/server:port/path?query
...
...
@@ -554,32 +554,12 @@ int SrsHttpMessage::update(string url, bool allow_jsonp, http_parser* header, Sr
return
ret
;
}
// must format as key=value&...&keyN=valueN
std
::
string
q
=
_uri
->
get_query
();
size_t
pos
=
string
::
npos
;
while
(
!
q
.
empty
())
{
std
::
string
k
=
q
;
if
((
pos
=
q
.
find
(
"="
))
!=
string
::
npos
)
{
k
=
q
.
substr
(
0
,
pos
);
q
=
q
.
substr
(
pos
+
1
);
}
else
{
q
=
""
;
}
std
::
string
v
=
q
;
if
((
pos
=
q
.
find
(
"&"
))
!=
string
::
npos
)
{
v
=
q
.
substr
(
0
,
pos
);
q
=
q
.
substr
(
pos
+
1
);
}
else
{
q
=
""
;
}
_query
[
k
]
=
v
;
}
// parse ext.
_ext
=
srs_path_filext
(
_uri
->
get_path
());
// parse query string.
srs_parse_query_string
(
_uri
->
get_query
(),
_query
);
// parse jsonp request message.
if
(
allow_jsonp
)
{
if
(
!
query_get
(
"callback"
).
empty
())
{
...
...
trunk/src/app/srs_app_utility.hpp
查看文件 @
f971538
...
...
@@ -654,6 +654,9 @@ extern void srs_update_rtmp_server(int nb_conn, SrsKbps* kbps);
// get local ip, fill to @param ips
extern
std
::
vector
<
std
::
string
>&
srs_get_local_ipv4_ips
();
// get local public ip, empty string if no public internet address found.
extern
std
::
string
srs_get_public_internet_address
();
// get local or peer ip.
// where local ip is the server ip which client connected.
extern
std
::
string
srs_get_local_ip
(
int
fd
);
...
...
trunk/src/protocol/srs_protocol_utility.cpp
查看文件 @
f971538
...
...
@@ -117,6 +117,27 @@ void srs_discovery_tc_url(
srs_vhost_resolve
(
vhost
,
app
,
param
);
}
void
srs_parse_query_string
(
string
q
,
map
<
string
,
string
>&
query
)
{
// query string flags.
static
vector
<
string
>
flags
;
if
(
flags
.
empty
())
{
flags
.
push_back
(
"="
);
flags
.
push_back
(
","
);
flags
.
push_back
(
"&&"
);
flags
.
push_back
(
"&"
);
flags
.
push_back
(
";"
);
}
vector
<
string
>
kvs
=
srs_string_split
(
q
,
flags
);
for
(
int
i
=
0
;
i
<
(
int
)
kvs
.
size
();
i
+=
2
)
{
string
k
=
kvs
.
at
(
i
);
string
v
=
(
i
<
(
int
)
kvs
.
size
()
-
1
)
?
kvs
.
at
(
i
+
1
)
:
""
;
query
[
k
]
=
v
;
}
}
void
srs_random_generate
(
char
*
bytes
,
int
size
)
{
static
bool
_random_initialized
=
false
;
...
...
请
注册
或
登录
后发表评论