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
c2b11e38
Commit
c2b11e38
authored
Feb 28, 2018
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善http超时管理
parent
d9dea060
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
15 行增加
和
16 行删除
+15
-16
src/Http/HttpClient.cpp
+2
-2
src/Http/HttpClient.h
+1
-1
src/Http/HttpClientImp.cpp
+2
-2
src/Http/HttpClientImp.h
+1
-1
src/Http/HttpDownloader.cpp
+2
-2
src/Http/HttpDownloader.h
+3
-4
src/Http/HttpRequester.cpp
+2
-2
src/Http/HttpRequester.h
+2
-2
没有找到文件。
src/Http/HttpClient.cpp
查看文件 @
c2b11e38
...
...
@@ -35,7 +35,7 @@ HttpClient::HttpClient(){
}
HttpClient
::~
HttpClient
(){
}
void
HttpClient
::
sendRequest
(
const
string
&
strUrl
){
void
HttpClient
::
sendRequest
(
const
string
&
strUrl
,
float
fTimeOutSec
){
auto
protocol
=
FindField
(
strUrl
.
data
(),
NULL
,
"://"
);
uint16_t
defaultPort
;
bool
isHttps
;
...
...
@@ -84,7 +84,7 @@ void HttpClient::sendRequest(const string &strUrl){
if
(
!
alive
()
||
bChanged
){
//InfoL << "reconnet:" << _lastHost;
startConnect
(
host
,
port
);
startConnect
(
host
,
port
,
fTimeOutSec
);
}
else
{
SockException
ex
;
onConnect
(
ex
);
...
...
src/Http/HttpClient.h
查看文件 @
c2b11e38
...
...
@@ -68,7 +68,7 @@ public:
typedef
std
::
shared_ptr
<
HttpClient
>
Ptr
;
HttpClient
();
virtual
~
HttpClient
();
virtual
void
sendRequest
(
const
string
&
url
);
virtual
void
sendRequest
(
const
string
&
url
,
float
fTimeOutSec
);
void
clear
(){
_header
.
clear
();
_body
.
clear
();
...
...
src/Http/HttpClientImp.cpp
查看文件 @
c2b11e38
...
...
@@ -37,8 +37,8 @@ HttpClientImp::HttpClientImp() {
HttpClientImp
::~
HttpClientImp
()
{
}
void
HttpClientImp
::
sendRequest
(
const
string
&
url
)
{
HttpClient
::
sendRequest
(
url
);
void
HttpClientImp
::
sendRequest
(
const
string
&
url
,
float
fTimeOutSec
)
{
HttpClient
::
sendRequest
(
url
,
fTimeOutSec
);
if
(
_isHttps
){
#ifndef ENABLE_OPENSSL
shutdown
();
...
...
src/Http/HttpClientImp.h
查看文件 @
c2b11e38
...
...
@@ -41,7 +41,7 @@ public:
typedef
std
::
shared_ptr
<
HttpClientImp
>
Ptr
;
HttpClientImp
();
virtual
~
HttpClientImp
();
virtual
void
sendRequest
(
const
string
&
url
)
override
;
virtual
void
sendRequest
(
const
string
&
url
,
float
fTimeOutSec
)
override
;
#if defined(__GNUC__) && (__GNUC__ < 5)
void
public_onRecvBytes
(
const
char
*
data
,
int
len
){
...
...
src/Http/HttpDownloader.cpp
查看文件 @
c2b11e38
...
...
@@ -41,7 +41,7 @@ HttpDownloader::~HttpDownloader() {
closeFile
();
}
void
HttpDownloader
::
startDownload
(
const
string
&
url
,
const
string
&
filePath
,
bool
bAppend
,
uint32_
t
timeOutSecond
)
{
void
HttpDownloader
::
startDownload
(
const
string
&
url
,
const
string
&
filePath
,
bool
bAppend
,
floa
t
timeOutSecond
)
{
_filePath
=
filePath
;
_timeOutSecond
=
timeOutSecond
;
_downloadTicker
.
resetTime
();
...
...
@@ -64,7 +64,7 @@ void HttpDownloader::startDownload(const string& url, const string& filePath,boo
addHeader
(
"Range"
,
StrPrinter
<<
"bytes="
<<
currentLen
<<
"-"
<<
endl
);
}
setMethod
(
"GET"
);
sendRequest
(
url
);
sendRequest
(
url
,
timeOutSecond
);
}
void
HttpDownloader
::
onResponseHeader
(
const
string
&
status
,
const
HttpHeader
&
headers
)
{
...
...
src/Http/HttpDownloader.h
查看文件 @
c2b11e38
...
...
@@ -39,11 +39,10 @@ public:
HttpDownloader
();
virtual
~
HttpDownloader
();
//开始下载文件,默认断点续传方式下载
void
startDownload
(
const
string
&
url
,
const
string
&
filePath
=
""
,
bool
bAppend
=
false
,
uint32_t
timeOutSecond
=
10
);
void
startDownload
(
const
string
&
url
,
const
onDownloadResult
&
cb
,
uint32_t
timeOutSecond
=
10
){
_timeOutSecond
=
timeOutSecond
;
void
startDownload
(
const
string
&
url
,
const
string
&
filePath
=
""
,
bool
bAppend
=
false
,
float
timeOutSecond
=
10
);
void
startDownload
(
const
string
&
url
,
const
onDownloadResult
&
cb
,
float
timeOutSecond
=
10
){
setOnResult
(
cb
);
startDownload
(
url
);
startDownload
(
url
,
""
,
false
,
timeOutSecond
);
}
void
setOnResult
(
const
onDownloadResult
&
cb
){
_onResult
=
cb
;
...
...
src/Http/HttpRequester.cpp
查看文件 @
c2b11e38
...
...
@@ -57,11 +57,11 @@ void HttpRequester::onDisconnect(const SockException &ex){
}
}
void
HttpRequester
::
startRequester
(
const
string
&
url
,
const
HttpRequesterResult
&
onResult
,
uint32_
t
timeOutSecond
){
void
HttpRequester
::
startRequester
(
const
string
&
url
,
const
HttpRequesterResult
&
onResult
,
floa
t
timeOutSecond
){
_onResult
=
onResult
;
_resTicker
.
resetTime
();
_timeOutSecond
=
timeOutSecond
;
sendRequest
(
url
);
sendRequest
(
url
,
timeOutSecond
);
}
void
HttpRequester
::
onManager
(){
...
...
src/Http/HttpRequester.h
查看文件 @
c2b11e38
...
...
@@ -40,7 +40,7 @@ public:
HttpRequester
();
virtual
~
HttpRequester
();
void
startRequester
(
const
string
&
url
,
const
HttpRequesterResult
&
onResult
,
uint32_
t
timeOutSecond
=
10
);
void
startRequester
(
const
string
&
url
,
const
HttpRequesterResult
&
onResult
,
floa
t
timeOutSecond
=
10
);
private
:
void
onResponseHeader
(
const
string
&
status
,
const
HttpHeader
&
headers
)
override
;
void
onResponseBody
(
const
char
*
buf
,
size_t
size
,
size_t
recvedSize
,
size_t
totalSize
)
override
;
...
...
@@ -50,7 +50,7 @@ private:
string
_strRecvBody
;
HttpRequesterResult
_onResult
;
Ticker
_resTicker
;
uint32_
t
_timeOutSecond
;
floa
t
_timeOutSecond
;
};
}
//namespace Http
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论