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
e3ab51b3
Commit
e3ab51b3
authored
Mar 27, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
简化ssl相关代码
parent
6d7f9877
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
10 行增加
和
69 行删除
+10
-69
ZLToolKit
+1
-1
src/Http/HttpClient.cpp
+1
-6
src/Http/HttpClient.h
+0
-10
src/Http/HttpClientImp.cpp
+5
-29
src/Http/HttpClientImp.h
+3
-23
没有找到文件。
ZLToolKit
@
ea623e89
Subproject commit
8e90a8dbefe9060fdb86b9dc8036345aa69faf41
Subproject commit
ea623e89153b7f5e4f693e3f2d4c5e60b79540ed
src/Http/HttpClient.cpp
查看文件 @
e3ab51b3
...
...
@@ -100,7 +100,6 @@ void HttpClient::sendRequest(const string &strUrl, float fTimeOutSec) {
if
(
!
alive
()
||
bChanged
)
{
//InfoL << "reconnet:" << _lastHost;
onBeforeConnect
(
host
,
port
,
fTimeOutSec
);
startConnect
(
host
,
port
,
fTimeOutSec
);
}
else
{
SockException
ex
;
...
...
@@ -132,12 +131,8 @@ void HttpClient::onConnect(const SockException &ex) {
}
void
HttpClient
::
onRecv
(
const
Buffer
::
Ptr
&
pBuf
)
{
onRecvBytes
(
pBuf
->
data
(),
pBuf
->
size
());
}
void
HttpClient
::
onRecvBytes
(
const
char
*
data
,
int
size
)
{
_aliveTicker
.
resetTime
();
HttpRequestSplitter
::
input
(
data
,
size
);
HttpRequestSplitter
::
input
(
pBuf
->
data
(),
pBuf
->
size
()
);
}
void
HttpClient
::
onErr
(
const
SockException
&
ex
)
{
...
...
src/Http/HttpClient.h
查看文件 @
e3ab51b3
...
...
@@ -284,13 +284,6 @@ protected:
}
/**
* 收到http回复数据回调
* @param data 数据指针
* @param size 数据大小
*/
virtual
void
onRecvBytes
(
const
char
*
data
,
int
size
);
/**
* http链接断开回调
* @param ex 断开原因
*/
...
...
@@ -299,9 +292,6 @@ protected:
//HttpRequestSplitter override
int64_t
onRecvHeader
(
const
char
*
data
,
uint64_t
len
)
override
;
void
onRecvContent
(
const
char
*
data
,
uint64_t
len
)
override
;
//在连接服务器前调用一次
virtual
void
onBeforeConnect
(
string
&
strUrl
,
uint16_t
&
iPort
,
float
&
fTimeOutSec
)
{};
protected
:
virtual
void
onConnect
(
const
SockException
&
ex
)
override
;
virtual
void
onRecv
(
const
Buffer
::
Ptr
&
pBuf
)
override
;
...
...
src/Http/HttpClientImp.cpp
查看文件 @
e3ab51b3
...
...
@@ -28,37 +28,13 @@
namespace
mediakit
{
#if defined(ENABLE_OPENSSL)
void
HttpClientImp
::
onBeforeConnect
(
string
&
strUrl
,
uint16_t
&
iPort
,
float
&
fTimeOutSec
)
{
if
(
_isHttps
){
_sslBox
.
reset
(
new
SSL_Box
(
false
));
_sslBox
->
setOnDecData
([
this
](
const
char
*
data
,
uint32_t
len
){
public_onRecvBytes
(
data
,
len
);
});
_sslBox
->
setOnEncData
([
this
](
const
char
*
data
,
uint32_t
len
){
public_send
(
data
,
len
);
});
}
else
{
_sslBox
.
reset
();
void
HttpClientImp
::
onConnect
(
const
SockException
&
ex
)
{
if
(
!
_isHttps
){
HttpClient
::
onConnect
(
ex
);
}
else
{
TcpClientWithSSL
<
HttpClient
>::
onConnect
(
ex
);
}
}
void
HttpClientImp
::
onRecvBytes
(
const
char
*
data
,
int
size
)
{
if
(
_sslBox
){
_sslBox
->
onRecv
(
data
,
size
);
}
else
{
HttpClient
::
onRecvBytes
(
data
,
size
);
}
}
int
HttpClientImp
::
send
(
const
Buffer
::
Ptr
&
buf
)
{
if
(
_sslBox
){
_sslBox
->
onSend
(
buf
->
data
(),
buf
->
size
());
return
buf
->
size
();
}
return
HttpClient
::
send
(
buf
);
}
#endif //defined(ENABLE_OPENSSL)
}
/* namespace mediakit */
src/Http/HttpClientImp.h
查看文件 @
e3ab51b3
...
...
@@ -28,41 +28,21 @@
#define SRC_HTTP_HTTPCLIENTIMP_H_
#include "HttpClient.h"
#ifdef ENABLE_OPENSSL
#include "Util/SSLBox.h"
#endif //ENABLE_OPENSSL
using
namespace
toolkit
;
namespace
mediakit
{
#if defined(ENABLE_OPENSSL)
class
HttpClientImp
:
public
HttpClient
{
class
HttpClientImp
:
public
TcpClientWithSSL
<
HttpClient
>
{
public
:
typedef
std
::
shared_ptr
<
HttpClientImp
>
Ptr
;
HttpClientImp
()
{}
virtual
~
HttpClientImp
()
{}
inline
void
public_onRecvBytes
(
const
char
*
data
,
int
len
){
HttpClient
::
onRecvBytes
(
data
,
len
);
}
inline
void
public_send
(
const
char
*
data
,
uint32_t
len
){
HttpClient
::
send
(
obtainBuffer
(
data
,
len
));
}
private
:
void
onRecvBytes
(
const
char
*
data
,
int
size
)
override
;
int
send
(
const
Buffer
::
Ptr
&
buf
)
override
;
void
onBeforeConnect
(
string
&
strUrl
,
uint16_t
&
iPort
,
float
&
fTimeOutSec
)
override
;
private
:
std
::
shared_ptr
<
SSL_Box
>
_sslBox
;
protected
:
void
onConnect
(
const
SockException
&
ex
)
override
;
};
#else
typedef
HttpClient
HttpClientImp
;
#endif // defined(ENABLE_OPENSSL)
}
/* namespace mediakit */
#endif
/* SRC_HTTP_HTTPCLIENTIMP_H_ */
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论