summaryrefslogtreecommitdiff
path: root/plugins/http
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/http')
-rw-r--r--plugins/http/plugin.go9
-rw-r--r--plugins/http/tests/configs/.rr-h2c.yaml9
-rw-r--r--plugins/http/tests/configs/.rr-ssl-push.yaml8
-rw-r--r--plugins/http/tests/configs/.rr-ssl-redirect.yaml8
-rw-r--r--plugins/http/tests/configs/.rr-ssl.yaml2
-rw-r--r--plugins/http/tests/http_test.go4
-rw-r--r--plugins/http/tests/uploads_test.go4
-rw-r--r--plugins/http/uploads.go6
8 files changed, 15 insertions, 35 deletions
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go
index 371cdb91..a6399489 100644
--- a/plugins/http/plugin.go
+++ b/plugins/http/plugin.go
@@ -183,6 +183,11 @@ func (s *Plugin) Serve() chan error {
s.fcgi = &http.Server{Handler: s}
}
+ // apply middlewares before starting the server
+ if len(s.mdwr) > 0 {
+ s.addMiddlewares()
+ }
+
if s.http != nil {
go func() {
httpErr := s.http.ListenAndServe()
@@ -217,10 +222,6 @@ func (s *Plugin) Serve() chan error {
}()
}
- if len(s.mdwr) > 0 {
- s.addMiddlewares()
- }
-
return errCh
}
diff --git a/plugins/http/tests/configs/.rr-h2c.yaml b/plugins/http/tests/configs/.rr-h2c.yaml
index 316daea9..d1b24338 100644
--- a/plugins/http/tests/configs/.rr-h2c.yaml
+++ b/plugins/http/tests/configs/.rr-h2c.yaml
@@ -20,15 +20,6 @@ http:
maxJobs: 0
allocateTimeout: 60s
destroyTimeout: 60s
-
- ssl:
- port: 8891
- redirect: false
- cert: fixtures/server.crt
- key: fixtures/server.key
- # rootCa: root.crt
- fcgi:
- address: tcp://0.0.0.0:6920
http2:
enabled: true
h2c: true
diff --git a/plugins/http/tests/configs/.rr-ssl-push.yaml b/plugins/http/tests/configs/.rr-ssl-push.yaml
index 90a99192..02de906a 100644
--- a/plugins/http/tests/configs/.rr-ssl-push.yaml
+++ b/plugins/http/tests/configs/.rr-ssl-push.yaml
@@ -26,10 +26,4 @@ http:
redirect: true
cert: fixtures/server.crt
key: fixtures/server.key
- # rootCa: root.crt
- fcgi:
- address: tcp://0.0.0.0:6920
- http2:
- enabled: false
- h2c: false
- maxConcurrentStreams: 128 \ No newline at end of file
+ # rootCa: root.crt \ No newline at end of file
diff --git a/plugins/http/tests/configs/.rr-ssl-redirect.yaml b/plugins/http/tests/configs/.rr-ssl-redirect.yaml
index 1878ba53..0ba1753e 100644
--- a/plugins/http/tests/configs/.rr-ssl-redirect.yaml
+++ b/plugins/http/tests/configs/.rr-ssl-redirect.yaml
@@ -26,10 +26,4 @@ http:
redirect: true
cert: fixtures/server.crt
key: fixtures/server.key
- # rootCa: root.crt
- fcgi:
- address: tcp://0.0.0.0:6920
- http2:
- enabled: false
- h2c: false
- maxConcurrentStreams: 128 \ No newline at end of file
+ # rootCa: root.crt \ No newline at end of file
diff --git a/plugins/http/tests/configs/.rr-ssl.yaml b/plugins/http/tests/configs/.rr-ssl.yaml
index 127c1678..fb54d3fa 100644
--- a/plugins/http/tests/configs/.rr-ssl.yaml
+++ b/plugins/http/tests/configs/.rr-ssl.yaml
@@ -28,7 +28,7 @@ http:
key: fixtures/server.key
# rootCa: root.crt
fcgi:
- address: tcp://0.0.0.0:6920
+ address: tcp://0.0.0.0:16920
http2:
enabled: false
h2c: false
diff --git a/plugins/http/tests/http_test.go b/plugins/http/tests/http_test.go
index 06bf3f5d..f68cd42c 100644
--- a/plugins/http/tests/http_test.go
+++ b/plugins/http/tests/http_test.go
@@ -17,7 +17,7 @@ import (
"github.com/golang/mock/gomock"
"github.com/spiral/endure"
- "github.com/spiral/goridge/v2"
+ "github.com/spiral/goridge/v3"
"github.com/spiral/roadrunner/v2"
"github.com/spiral/roadrunner/v2/mocks"
"github.com/spiral/roadrunner/v2/plugins/config"
@@ -334,7 +334,7 @@ func sslEcho(t *testing.T) {
}
func fcgiEcho(t *testing.T) {
- fcgiConnFactory := gofast.SimpleConnFactory("tcp", "0.0.0.0:6920")
+ fcgiConnFactory := gofast.SimpleConnFactory("tcp", "0.0.0.0:16920")
fcgiHandler := gofast.NewHandler(
gofast.BasicParamsMap(gofast.BasicSession),
diff --git a/plugins/http/tests/uploads_test.go b/plugins/http/tests/uploads_test.go
index ee244c06..d36d4793 100644
--- a/plugins/http/tests/uploads_test.go
+++ b/plugins/http/tests/uploads_test.go
@@ -269,7 +269,7 @@ func TestHandler_Upload_File_NoTmpDir(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 200, r.StatusCode)
- fs := fileString(testFile, 5, "application/octet-stream")
+ fs := fileString(testFile, 6, "application/octet-stream")
assert.Equal(t, `{"upload":`+fs+`}`, string(b))
}
@@ -352,7 +352,7 @@ func TestHandler_Upload_File_Forbids(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 200, r.StatusCode)
- fs := fileString(testFile, 7, "application/octet-stream")
+ fs := fileString(testFile, 8, "application/octet-stream")
assert.Equal(t, `{"upload":`+fs+`}`, string(b))
}
diff --git a/plugins/http/uploads.go b/plugins/http/uploads.go
index 5fddb75d..aeb41591 100644
--- a/plugins/http/uploads.go
+++ b/plugins/http/uploads.go
@@ -18,13 +18,13 @@ const (
UploadErrorNoFile = 4
// UploadErrorNoTmpDir - missing a temporary folder.
- UploadErrorNoTmpDir = 5
+ UploadErrorNoTmpDir = 6
// UploadErrorCantWrite - failed to write file to disk.
- UploadErrorCantWrite = 6
+ UploadErrorCantWrite = 7
// UploadErrorExtension - forbidden file extension.
- UploadErrorExtension = 7
+ UploadErrorExtension = 8
)
// Uploads tree manages uploaded files tree and temporary files.