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
f6c508f1
Commit
f6c508f1
authored
Dec 21, 2015
by
fud
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://github.com/astaxie/beego
into develop
parents
f9138c5a
130ce7eb
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
9 deletions
+26
-9
acceptencoder.go
context/acceptencoder.go
+6
-1
types.go
orm/types.go
+0
-0
cors_test.go
plugins/cors/cors_test.go
+2
-2
staticfile_test.go
staticfile_test.go
+2
-2
tree.go
tree.go
+16
-4
No files found.
context/acceptencoder.go
View file @
f6c508f1
...
@@ -18,6 +18,7 @@ import (
...
@@ -18,6 +18,7 @@ import (
"bytes"
"bytes"
"compress/flate"
"compress/flate"
"compress/gzip"
"compress/gzip"
"compress/zlib"
"io"
"io"
"net/http"
"net/http"
"os"
"os"
...
@@ -33,7 +34,11 @@ type acceptEncoder struct {
...
@@ -33,7 +34,11 @@ type acceptEncoder struct {
var
(
var
(
noneCompressEncoder
=
acceptEncoder
{
""
,
func
(
wr
io
.
Writer
,
level
int
)
(
io
.
Writer
,
error
)
{
return
wr
,
nil
}}
noneCompressEncoder
=
acceptEncoder
{
""
,
func
(
wr
io
.
Writer
,
level
int
)
(
io
.
Writer
,
error
)
{
return
wr
,
nil
}}
gzipCompressEncoder
=
acceptEncoder
{
"gzip"
,
func
(
wr
io
.
Writer
,
level
int
)
(
io
.
Writer
,
error
)
{
return
gzip
.
NewWriterLevel
(
wr
,
level
)
}}
gzipCompressEncoder
=
acceptEncoder
{
"gzip"
,
func
(
wr
io
.
Writer
,
level
int
)
(
io
.
Writer
,
error
)
{
return
gzip
.
NewWriterLevel
(
wr
,
level
)
}}
deflateCompressEncoder
=
acceptEncoder
{
"deflate"
,
func
(
wr
io
.
Writer
,
level
int
)
(
io
.
Writer
,
error
)
{
return
flate
.
NewWriter
(
wr
,
level
)
}}
//according to the sec :http://tools.ietf.org/html/rfc2616#section-3.5 ,the deflate compress in http is zlib indeed
//deflate
//The "zlib" format defined in RFC 1950 [31] in combination with
//the "deflate" compression mechanism described in RFC 1951 [29].
deflateCompressEncoder
=
acceptEncoder
{
"deflate"
,
func
(
wr
io
.
Writer
,
level
int
)
(
io
.
Writer
,
error
)
{
return
zlib
.
NewWriterLevel
(
wr
,
level
)
}}
)
)
var
(
var
(
...
...
orm/types.go
View file @
f6c508f1
This diff is collapsed.
Click to expand it.
plugins/cors/cors_test.go
View file @
f6c508f1
...
@@ -225,8 +225,8 @@ func Benchmark_WithoutCORS(b *testing.B) {
...
@@ -225,8 +225,8 @@ func Benchmark_WithoutCORS(b *testing.B) {
ctx
.
Output
.
SetStatus
(
500
)
ctx
.
Output
.
SetStatus
(
500
)
})
})
b
.
ResetTimer
()
b
.
ResetTimer
()
for
i
:=
0
;
i
<
100
;
i
++
{
r
,
_
:=
http
.
NewRequest
(
"PUT"
,
"/foo"
,
nil
)
r
,
_
:=
http
.
NewRequest
(
"PUT"
,
"/foo"
,
nil
)
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
handler
.
ServeHTTP
(
recorder
,
r
)
handler
.
ServeHTTP
(
recorder
,
r
)
}
}
}
}
...
@@ -246,8 +246,8 @@ func Benchmark_WithCORS(b *testing.B) {
...
@@ -246,8 +246,8 @@ func Benchmark_WithCORS(b *testing.B) {
ctx
.
Output
.
SetStatus
(
500
)
ctx
.
Output
.
SetStatus
(
500
)
})
})
b
.
ResetTimer
()
b
.
ResetTimer
()
for
i
:=
0
;
i
<
100
;
i
++
{
r
,
_
:=
http
.
NewRequest
(
"PUT"
,
"/foo"
,
nil
)
r
,
_
:=
http
.
NewRequest
(
"PUT"
,
"/foo"
,
nil
)
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
handler
.
ServeHTTP
(
recorder
,
r
)
handler
.
ServeHTTP
(
recorder
,
r
)
}
}
}
}
staticfile_test.go
View file @
f6c508f1
...
@@ -2,8 +2,8 @@ package beego
...
@@ -2,8 +2,8 @@ package beego
import
(
import
(
"bytes"
"bytes"
"compress/flate"
"compress/gzip"
"compress/gzip"
"compress/zlib"
"io"
"io"
"io/ioutil"
"io/ioutil"
"os"
"os"
...
@@ -43,7 +43,7 @@ func TestOpenStaticFileGzip_1(t *testing.T) {
...
@@ -43,7 +43,7 @@ func TestOpenStaticFileGzip_1(t *testing.T) {
func
TestOpenStaticFileDeflate_1
(
t
*
testing
.
T
)
{
func
TestOpenStaticFileDeflate_1
(
t
*
testing
.
T
)
{
file
,
_
:=
os
.
Open
(
licenseFile
)
file
,
_
:=
os
.
Open
(
licenseFile
)
var
zipBuf
bytes
.
Buffer
var
zipBuf
bytes
.
Buffer
fileWriter
,
_
:=
flate
.
NewWriter
(
&
zipBuf
,
flate
.
BestCompression
)
fileWriter
,
_
:=
zlib
.
NewWriterLevel
(
&
zipBuf
,
zlib
.
BestCompression
)
io
.
Copy
(
fileWriter
,
file
)
io
.
Copy
(
fileWriter
,
file
)
fileWriter
.
Close
()
fileWriter
.
Close
()
content
,
_
:=
ioutil
.
ReadAll
(
&
zipBuf
)
content
,
_
:=
ioutil
.
ReadAll
(
&
zipBuf
)
...
...
tree.go
View file @
f6c508f1
...
@@ -334,7 +334,7 @@ func (t *Tree) match(pattern string, wildcardValues []string, ctx *context.Conte
...
@@ -334,7 +334,7 @@ func (t *Tree) match(pattern string, wildcardValues []string, ctx *context.Conte
}
}
}
}
}
}
if
runObject
==
nil
{
if
runObject
==
nil
&&
len
(
t
.
fixrouters
)
>
0
{
// Filter the .json .xml .html extension
// Filter the .json .xml .html extension
for
_
,
str
:=
range
allowSuffixExt
{
for
_
,
str
:=
range
allowSuffixExt
{
if
strings
.
HasSuffix
(
seg
,
str
)
{
if
strings
.
HasSuffix
(
seg
,
str
)
{
...
@@ -353,11 +353,23 @@ func (t *Tree) match(pattern string, wildcardValues []string, ctx *context.Conte
...
@@ -353,11 +353,23 @@ func (t *Tree) match(pattern string, wildcardValues []string, ctx *context.Conte
runObject
=
t
.
wildcard
.
match
(
pattern
,
append
(
wildcardValues
,
seg
),
ctx
)
runObject
=
t
.
wildcard
.
match
(
pattern
,
append
(
wildcardValues
,
seg
),
ctx
)
}
}
if
runObject
==
nil
{
if
runObject
==
nil
&&
len
(
t
.
leaves
)
>
0
{
segments
:=
splitPath
(
pattern
)
wildcardValues
=
append
(
wildcardValues
,
seg
)
wildcardValues
=
append
(
wildcardValues
,
seg
)
start
,
i
:=
0
,
0
for
;
i
<
len
(
pattern
);
i
++
{
if
pattern
[
i
]
==
'/'
{
if
i
!=
0
&&
start
<
len
(
pattern
)
{
wildcardValues
=
append
(
wildcardValues
,
pattern
[
start
:
i
])
}
start
=
i
+
1
continue
}
}
if
start
>
0
{
wildcardValues
=
append
(
wildcardValues
,
pattern
[
start
:
i
])
}
for
_
,
l
:=
range
t
.
leaves
{
for
_
,
l
:=
range
t
.
leaves
{
if
ok
:=
l
.
match
(
append
(
wildcardValues
,
segments
...
)
,
ctx
);
ok
{
if
ok
:=
l
.
match
(
wildcardValues
,
ctx
);
ok
{
return
l
.
runObject
return
l
.
runObject
}
}
}
}
...
...
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