Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
43e1cc69
Commit
43e1cc69
authored
Oct 29, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化http服务器
parent
fd10ef11
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
6 行增加
和
10 行删除
+6
-10
server/WebApi.cpp
+1
-6
src/Http/HttpSession.cpp
+0
-0
src/Http/HttpSession.h
+5
-4
没有找到文件。
server/WebApi.cpp
查看文件 @
43e1cc69
...
...
@@ -616,12 +616,7 @@ void installWebApi() {
//测试url http://127.0.0.1/index/api/downloadBin
API_REGIST_INVOKER
(
api
,
downloadBin
,{
CHECK_SECRET
();
auto
body
=
std
::
make_shared
<
HttpFileBody
>
(
exePath
());
if
(
!
body
->
remainSize
()){
invoker
(
"404 Not Found"
,
HttpSession
::
KeyValue
(),
""
);
return
;
}
invoker
(
"200 OK"
,
HttpSession
::
KeyValue
(),
body
);
invoker
.
responseFile
(
headerIn
,
StrCaseMap
(),
exePath
());
});
////////////以下是注册的Hook API////////////
...
...
src/Http/HttpSession.cpp
查看文件 @
43e1cc69
差异被折叠。
点击展开。
src/Http/HttpSession.h
查看文件 @
43e1cc69
...
...
@@ -61,6 +61,7 @@ public:
void
operator
()(
const
string
&
codeOut
,
const
StrCaseMap
&
headerOut
,
const
HttpBody
::
Ptr
&
body
)
const
;
void
operator
()(
const
string
&
codeOut
,
const
StrCaseMap
&
headerOut
,
const
string
&
body
)
const
;
void
responseFile
(
const
StrCaseMap
&
requestHeader
,
const
StrCaseMap
&
responseHeader
,
const
string
&
filePath
)
const
;
operator
bool
();
private
:
HttpResponseInvokerLambda0
_lambad
;
...
...
@@ -89,6 +90,7 @@ public:
virtual
void
onManager
()
override
;
static
string
urlDecode
(
const
string
&
str
);
static
const
char
*
get_mime_type
(
const
char
*
name
);
protected
:
//FlvMuxer override
void
onWrite
(
const
Buffer
::
Ptr
&
data
)
override
;
...
...
@@ -140,10 +142,9 @@ private:
bool
emitHttpEvent
(
bool
doInvoke
);
void
urlDecode
(
Parser
&
parser
);
void
sendNotFound
(
bool
bClose
);
void
sendResponse
(
const
char
*
pcStatus
,
const
KeyValue
&
header
,
const
string
&
strContent
);
void
sendResponse
(
const
char
*
pcStatus
,
const
KeyValue
&
header
,
const
HttpBody
::
Ptr
&
body
,
bool
bClose
);
KeyValue
makeHttpHeader
(
bool
bClose
=
false
,
int64_t
iContentSize
=-
1
,
const
char
*
pcContentType
=
"text/html"
);
void
sendResponse
(
const
char
*
pcStatus
,
bool
bClose
,
const
char
*
pcContentType
=
nullptr
,
const
HttpSession
::
KeyValue
&
header
=
HttpSession
::
KeyValue
(),
const
HttpBody
::
Ptr
&
body
=
nullptr
,
bool
set_content_len
=
true
);
/**
* 判断http客户端是否有权限访问文件的逻辑步骤
*
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论