Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
03037170
Commit
03037170
authored
Feb 22, 2014
by
slene
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update output.Cookie
parent
002e0854
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
19 deletions
+35
-19
output.go
context/output.go
+35
-19
No files found.
context/output.go
View file @
03037170
...
@@ -77,43 +77,59 @@ func (output *BeegoOutput) Cookie(name string, value string, others ...interface
...
@@ -77,43 +77,59 @@ func (output *BeegoOutput) Cookie(name string, value string, others ...interface
var
b
bytes
.
Buffer
var
b
bytes
.
Buffer
fmt
.
Fprintf
(
&
b
,
"%s=%s"
,
sanitizeName
(
name
),
sanitizeValue
(
value
))
fmt
.
Fprintf
(
&
b
,
"%s=%s"
,
sanitizeName
(
name
),
sanitizeValue
(
value
))
if
len
(
others
)
>
0
{
if
len
(
others
)
>
0
{
switch
others
[
0
]
.
(
type
)
{
switch
v
:=
others
[
0
]
.
(
type
)
{
case
int
:
case
int
:
if
others
[
0
]
.
(
int
)
>
0
{
if
v
>
0
{
fmt
.
Fprintf
(
&
b
,
"; Max-Age=%d"
,
others
[
0
]
.
(
int
)
)
fmt
.
Fprintf
(
&
b
,
"; Max-Age=%d"
,
v
)
}
else
if
others
[
0
]
.
(
int
)
<
0
{
}
else
if
v
<
0
{
fmt
.
Fprintf
(
&
b
,
"; Max-Age=0"
)
fmt
.
Fprintf
(
&
b
,
"; Max-Age=0"
)
}
}
case
int64
:
case
int64
:
if
others
[
0
]
.
(
int64
)
>
0
{
if
v
>
0
{
fmt
.
Fprintf
(
&
b
,
"; Max-Age=%d"
,
others
[
0
]
.
(
int64
)
)
fmt
.
Fprintf
(
&
b
,
"; Max-Age=%d"
,
v
)
}
else
if
others
[
0
]
.
(
int64
)
<
0
{
}
else
if
v
<
0
{
fmt
.
Fprintf
(
&
b
,
"; Max-Age=0"
)
fmt
.
Fprintf
(
&
b
,
"; Max-Age=0"
)
}
}
case
int32
:
case
int32
:
if
others
[
0
]
.
(
int32
)
>
0
{
if
v
>
0
{
fmt
.
Fprintf
(
&
b
,
"; Max-Age=%d"
,
others
[
0
]
.
(
int32
)
)
fmt
.
Fprintf
(
&
b
,
"; Max-Age=%d"
,
v
)
}
else
if
others
[
0
]
.
(
int32
)
<
0
{
}
else
if
v
<
0
{
fmt
.
Fprintf
(
&
b
,
"; Max-Age=0"
)
fmt
.
Fprintf
(
&
b
,
"; Max-Age=0"
)
}
}
}
}
}
}
if
len
(
others
)
>
1
{
if
len
(
others
)
>
1
{
if
len
(
others
[
1
]
.
(
string
))
==
0
{
if
v
,
ok
:=
others
[
1
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
fmt
.
Fprintf
(
&
b
,
"; Path=%s"
,
'/'
)
fmt
.
Fprintf
(
&
b
,
"; Path=%s"
,
sanitizeValue
(
v
)
)
}
else
{
}
else
{
fmt
.
Fprintf
(
&
b
,
"; Path=%s"
,
sanitizeValue
(
others
[
1
]
.
(
string
))
)
fmt
.
Fprintf
(
&
b
,
"; Path=%s"
,
'/'
)
}
}
}
}
if
len
(
others
)
>
2
&&
len
(
others
[
2
]
.
(
string
))
>
0
{
if
len
(
others
)
>
2
{
fmt
.
Fprintf
(
&
b
,
"; Domain=%s"
,
sanitizeValue
(
others
[
2
]
.
(
string
)))
if
v
,
ok
:=
others
[
2
]
.
(
string
);
ok
&&
len
(
v
)
>
0
{
fmt
.
Fprintf
(
&
b
,
"; Domain=%s"
,
sanitizeValue
(
v
))
}
}
}
if
len
(
others
)
>
3
&&
others
[
3
]
.
(
bool
)
{
if
len
(
others
)
>
3
{
fmt
.
Fprintf
(
&
b
,
"; Secure"
)
var
secure
bool
switch
v
:=
others
[
3
]
.
(
type
)
{
case
bool
:
secure
=
v
default
:
secure
=
true
}
if
secure
{
fmt
.
Fprintf
(
&
b
,
"; Secure"
)
}
}
}
if
!
(
len
(
others
)
>
4
&&
others
[
4
]
.
(
bool
)
==
false
)
{
if
len
(
others
)
>
4
{
fmt
.
Fprintf
(
&
b
,
"; HttpOnly"
)
if
v
,
ok
:=
others
[
4
]
.
(
bool
);
ok
&&
!
v
{
// HttpOnly = false
}
else
{
fmt
.
Fprintf
(
&
b
,
"; HttpOnly"
)
}
}
}
output
.
Context
.
ResponseWriter
.
Header
()
.
Add
(
"Set-Cookie"
,
b
.
String
())
output
.
Context
.
ResponseWriter
.
Header
()
.
Add
(
"Set-Cookie"
,
b
.
String
())
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment