Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
d47b0419
Commit
d47b0419
authored
Sep 03, 2018
by
Alexander Danilov
Committed by
Matt Holt
Sep 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fastcgi: Add default timeouts (#2265)
Default fastcgi timeout is 60 seconds Add tests
parent
dfbc2e81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
12 deletions
+48
-12
caddyhttp/fastcgi/setup.go
caddyhttp/fastcgi/setup.go
+7
-2
caddyhttp/fastcgi/setup_test.go
caddyhttp/fastcgi/setup_test.go
+41
-10
No files found.
caddyhttp/fastcgi/setup.go
View file @
d47b0419
...
...
@@ -27,6 +27,8 @@ import (
"github.com/mholt/caddy/caddyhttp/httpserver"
)
var
defaultTimeout
=
60
*
time
.
Second
func
init
()
{
caddy
.
RegisterPlugin
(
"fastcgi"
,
caddy
.
Plugin
{
ServerType
:
"http"
,
...
...
@@ -76,8 +78,11 @@ func fastcgiParse(c *caddy.Controller) ([]Rule, error) {
}
rule
:=
Rule
{
Root
:
absRoot
,
Path
:
args
[
0
],
Root
:
absRoot
,
Path
:
args
[
0
],
ConnectTimeout
:
defaultTimeout
,
ReadTimeout
:
defaultTimeout
,
SendTimeout
:
defaultTimeout
,
}
upstreams
:=
[]
string
{
args
[
1
]}
...
...
caddyhttp/fastcgi/setup_test.go
View file @
d47b0419
...
...
@@ -19,6 +19,7 @@ import (
"fmt"
"net"
"testing"
"time"
"github.com/mholt/caddy"
"github.com/mholt/caddy/caddyhttp/httpserver"
...
...
@@ -53,6 +54,18 @@ func TestSetup(t *testing.T) {
if
addr
!=
"127.0.0.1:9000"
{
t
.
Errorf
(
"Expected 127.0.0.1:9000 as the Address"
)
}
if
myHandler
.
Rules
[
0
]
.
ConnectTimeout
!=
60
*
time
.
Second
{
t
.
Errorf
(
"Expected default value of 60 seconds"
)
}
if
myHandler
.
Rules
[
0
]
.
ReadTimeout
!=
60
*
time
.
Second
{
t
.
Errorf
(
"Expected default value of 60 seconds"
)
}
if
myHandler
.
Rules
[
0
]
.
SendTimeout
!=
60
*
time
.
Second
{
t
.
Errorf
(
"Expected default value of 60 seconds"
)
}
}
func
TestFastcgiParse
(
t
*
testing
.
T
)
{
...
...
@@ -64,21 +77,23 @@ func TestFastcgiParse(t *testing.T) {
{
`fastcgi /blog 127.0.0.1:9000 php`
,
false
,
[]
Rule
{{
Path
:
"/blog"
,
balancer
:
&
roundRobin
{
addresses
:
[]
string
{
"127.0.0.1:9000"
}},
Ext
:
".php"
,
SplitPath
:
".php"
,
IndexFiles
:
[]
string
{
"index.php"
},
Path
:
"/blog"
,
balancer
:
&
roundRobin
{
addresses
:
[]
string
{
"127.0.0.1:9000"
}},
Ext
:
".php"
,
SplitPath
:
".php"
,
IndexFiles
:
[]
string
{
"index.php"
},
SendTimeout
:
60
*
time
.
Second
,
}}},
{
`fastcgi / 127.0.0.1:9001 {
split .html
}`
,
false
,
[]
Rule
{{
Path
:
"/"
,
balancer
:
&
roundRobin
{
addresses
:
[]
string
{
"127.0.0.1:9001"
}},
Ext
:
""
,
SplitPath
:
".html"
,
IndexFiles
:
[]
string
{},
Path
:
"/"
,
balancer
:
&
roundRobin
{
addresses
:
[]
string
{
"127.0.0.1:9001"
}},
Ext
:
""
,
SplitPath
:
".html"
,
IndexFiles
:
[]
string
{},
SendTimeout
:
60
*
time
.
Second
,
}}},
{
`fastcgi / 127.0.0.1:9001 {
split .html
...
...
@@ -91,6 +106,17 @@ func TestFastcgiParse(t *testing.T) {
SplitPath
:
".html"
,
IndexFiles
:
[]
string
{},
IgnoredSubPaths
:
[]
string
{
"/admin"
,
"/user"
},
SendTimeout
:
60
*
time
.
Second
,
}}},
{
`fastcgi / 127.0.0.1:9001 {
send_timeout 30s
}`
,
false
,
[]
Rule
{{
Path
:
"/"
,
balancer
:
&
roundRobin
{
addresses
:
[]
string
{
"127.0.0.1:9001"
}},
Ext
:
""
,
IndexFiles
:
[]
string
{},
SendTimeout
:
30
*
time
.
Second
,
}}},
}
for
i
,
test
:=
range
tests
{
...
...
@@ -146,6 +172,11 @@ func TestFastcgiParse(t *testing.T) {
t
.
Errorf
(
"Test %d expected %dth FastCGI IgnoredSubPaths to be %s , but got %s"
,
i
,
j
,
test
.
expectedFastcgiConfig
[
j
]
.
IgnoredSubPaths
,
actualFastcgiConfig
.
IgnoredSubPaths
)
}
if
actualFastcgiConfig
.
SendTimeout
!=
test
.
expectedFastcgiConfig
[
j
]
.
SendTimeout
{
t
.
Errorf
(
"Test %d expected %dth FastCGI SendTimeout to be %s , but got %s"
,
i
,
j
,
test
.
expectedFastcgiConfig
[
j
]
.
SendTimeout
,
actualFastcgiConfig
.
SendTimeout
)
}
}
}
...
...
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