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
0603e955
Commit
0603e955
authored
6 years ago
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复cookie过期判断不准的bug
parent
327acdf5
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
23 行增加
和
10 行删除
+23
-10
src/Http/HttpClient.cpp
+10
-5
src/Http/HttpClient.h
+1
-1
src/Http/HttpCookie.cpp
+11
-3
src/Http/HttpCookie.h
+1
-1
没有找到文件。
src/Http/HttpClient.cpp
查看文件 @
0603e955
...
@@ -255,7 +255,7 @@ void HttpClient::onResponseCompleted_l() {
...
@@ -255,7 +255,7 @@ void HttpClient::onResponseCompleted_l() {
onResponseCompleted
();
onResponseCompleted
();
}
}
void
HttpClient
::
checkCookie
(
const
HttpClient
::
HttpHeader
&
headers
)
{
void
HttpClient
::
checkCookie
(
HttpClient
::
HttpHeader
&
headers
)
{
//Set-Cookie: IPTV_SERVER=8E03927B-CC8C-4389-BC00-31DBA7EC7B49;expires=Sun, Sep 23 2018 15:07:31 GMT;path=/index/api/
//Set-Cookie: IPTV_SERVER=8E03927B-CC8C-4389-BC00-31DBA7EC7B49;expires=Sun, Sep 23 2018 15:07:31 GMT;path=/index/api/
auto
it_set_cookie
=
headers
.
find
(
"Set-Cookie"
);
auto
it_set_cookie
=
headers
.
find
(
"Set-Cookie"
);
if
(
it_set_cookie
==
headers
.
end
()){
if
(
it_set_cookie
==
headers
.
end
()){
...
@@ -274,12 +274,17 @@ void HttpClient::checkCookie(const HttpClient::HttpHeader &headers) {
...
@@ -274,12 +274,17 @@ void HttpClient::checkCookie(const HttpClient::HttpHeader &headers) {
if
(
index
++
==
0
){
if
(
index
++
==
0
){
cookie
->
setKeyVal
(
key
,
val
);
cookie
->
setKeyVal
(
key
,
val
);
}
else
{
continue
;
if
(
key
==
"path"
){
}
if
(
key
==
"path"
)
{
cookie
->
setPath
(
val
);
cookie
->
setPath
(
val
);
}
else
if
(
key
==
"expires"
){
continue
;
cookie
->
setExpires
(
val
);
}
}
if
(
key
==
"expires"
){
cookie
->
setExpires
(
val
,
headers
[
"Date"
]);
continue
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/Http/HttpClient.h
查看文件 @
0603e955
...
@@ -310,7 +310,7 @@ protected:
...
@@ -310,7 +310,7 @@ protected:
virtual
void
onManager
()
override
;
virtual
void
onManager
()
override
;
private
:
private
:
void
onResponseCompleted_l
();
void
onResponseCompleted_l
();
void
checkCookie
(
const
HttpHeader
&
headers
);
void
checkCookie
(
HttpHeader
&
headers
);
protected
:
protected
:
bool
_isHttps
;
bool
_isHttps
;
private
:
private
:
...
...
This diff is collapsed.
Click to expand it.
src/Http/HttpCookie.cpp
查看文件 @
0603e955
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include "HttpCookie.h"
#include "HttpCookie.h"
#include "Util/util.h"
#include "Util/util.h"
#include "Util/logger.h"
#if defined(_WIN32)
#if defined(_WIN32)
#include "strptime_win.h"
#include "strptime_win.h"
...
@@ -40,10 +41,17 @@ void HttpCookie::setPath(const string &path){
...
@@ -40,10 +41,17 @@ void HttpCookie::setPath(const string &path){
void
HttpCookie
::
setHost
(
const
string
&
host
){
void
HttpCookie
::
setHost
(
const
string
&
host
){
_host
=
host
;
_host
=
host
;
}
}
void
HttpCookie
::
setExpires
(
const
string
&
expires
){
static
uint32_t
timeStrToInt
(
const
string
&
date
){
struct
tm
tt
;
struct
tm
tt
;
strptime
(
expires
.
data
(),
"%a, %b %d %Y %H:%M:%S %Z"
,
&
tt
);
strptime
(
date
.
data
(),
"%a, %b %d %Y %H:%M:%S %Z"
,
&
tt
);
_expire
=
mktime
(
&
tt
);
return
mktime
(
&
tt
);
}
void
HttpCookie
::
setExpires
(
const
string
&
expires
,
const
string
&
server_date
){
_expire
=
timeStrToInt
(
expires
);
if
(
!
server_date
.
empty
()){
_expire
=
time
(
NULL
)
+
(
_expire
-
timeStrToInt
(
server_date
));
// DebugL << (timeStrToInt(expires) - timeStrToInt(server_date)) / 60;
}
}
}
void
HttpCookie
::
setKeyVal
(
const
string
&
key
,
const
string
&
val
){
void
HttpCookie
::
setKeyVal
(
const
string
&
key
,
const
string
&
val
){
_key
=
key
;
_key
=
key
;
...
...
This diff is collapsed.
Click to expand it.
src/Http/HttpCookie.h
查看文件 @
0603e955
...
@@ -45,7 +45,7 @@ public:
...
@@ -45,7 +45,7 @@ public:
void
setPath
(
const
string
&
path
);
void
setPath
(
const
string
&
path
);
void
setHost
(
const
string
&
host
);
void
setHost
(
const
string
&
host
);
void
setExpires
(
const
string
&
expires
);
void
setExpires
(
const
string
&
expires
,
const
string
&
server_date
);
void
setKeyVal
(
const
string
&
key
,
const
string
&
val
);
void
setKeyVal
(
const
string
&
key
,
const
string
&
val
);
operator
bool
();
operator
bool
();
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论