diff options
author | Valery Piashchynski <[email protected]> | 2020-12-20 18:28:46 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-12-20 18:28:46 +0300 |
commit | f4a36c7f684216fb408693a6c494486144df57cf (patch) | |
tree | e1b61bf7e74cb63aa45f9ca0284a4cffe8e06b0e /plugins/http | |
parent | fbd5adde5abae6f7adb7fcdafc226bcd3480d498 (diff) | |
parent | a10d20d20e910ed8fcfbc3bc690aaf17ee338ff3 (diff) |
Merge remote-tracking branch 'origin/2.0' into plugin/redis
# Conflicts:
# go.sum
# pkg/pipe/pipe_factory_test.go
# pkg/pool/static_pool.go
# plugins/rpc/plugin.go
Diffstat (limited to 'plugins/http')
-rw-r--r-- | plugins/http/request.go | 10 | ||||
-rw-r--r-- | plugins/http/response.go | 4 | ||||
-rw-r--r-- | plugins/http/tests/http_test.go | 6 | ||||
-rw-r--r-- | plugins/http/tests/response_test.go | 16 |
4 files changed, 18 insertions, 18 deletions
diff --git a/plugins/http/request.go b/plugins/http/request.go index 5df79b7d..d613bcf6 100644 --- a/plugins/http/request.go +++ b/plugins/http/request.go @@ -10,7 +10,7 @@ import ( j "github.com/json-iterator/go" "github.com/spiral/roadrunner/v2/interfaces/log" - "github.com/spiral/roadrunner/v2/internal" + "github.com/spiral/roadrunner/v2/pkg/payload" "github.com/spiral/roadrunner/v2/plugins/http/attributes" ) @@ -136,17 +136,17 @@ func (r *Request) Close(log log.Logger) { // Payload request marshaled RoadRunner payload based on PSR7 data. values encode method is JSON. Make sure to open // files prior to calling this method. -func (r *Request) Payload() (internal.Payload, error) { - p := internal.Payload{} +func (r *Request) Payload() (payload.Payload, error) { + p := payload.Payload{} var err error if p.Context, err = json.Marshal(r); err != nil { - return internal.Payload{}, err + return payload.Payload{}, err } if r.Parsed { if p.Body, err = json.Marshal(r.body); err != nil { - return internal.Payload{}, err + return payload.Payload{}, err } } else if r.body != nil { p.Body = r.body.([]byte) diff --git a/plugins/http/response.go b/plugins/http/response.go index 9700a16c..17049ce1 100644 --- a/plugins/http/response.go +++ b/plugins/http/response.go @@ -6,7 +6,7 @@ import ( "strings" "sync" - "github.com/spiral/roadrunner/v2/internal" + "github.com/spiral/roadrunner/v2/pkg/payload" ) // Response handles PSR7 response logic. @@ -23,7 +23,7 @@ type Response struct { } // NewResponse creates new response based on given pool payload. -func NewResponse(p internal.Payload) (*Response, error) { +func NewResponse(p payload.Payload) (*Response, error) { r := &Response{Body: p.Body} if err := json.Unmarshal(p.Context, r); err != nil { return nil, err diff --git a/plugins/http/tests/http_test.go b/plugins/http/tests/http_test.go index 1a61597c..d7818981 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/v3" + goridgeRpc "github.com/spiral/goridge/v3/pkg/rpc" "github.com/spiral/roadrunner/v2" "github.com/spiral/roadrunner/v2/interfaces/events" "github.com/spiral/roadrunner/v2/mocks" @@ -193,7 +193,7 @@ func echoHTTP(t *testing.T) { func resetTest(t *testing.T) { conn, err := net.Dial("tcp", "127.0.0.1:6001") assert.NoError(t, err) - client := rpc.NewClientWithCodec(goridge.NewClientCodec(conn)) + client := rpc.NewClientWithCodec(goridgeRpc.NewClientCodec(conn)) // WorkerList contains list of workers. var ret bool @@ -213,7 +213,7 @@ func resetTest(t *testing.T) { func informerTest(t *testing.T) { conn, err := net.Dial("tcp", "127.0.0.1:6001") assert.NoError(t, err) - client := rpc.NewClientWithCodec(goridge.NewClientCodec(conn)) + client := rpc.NewClientWithCodec(goridgeRpc.NewClientCodec(conn)) // WorkerList contains list of workers. list := struct { // Workers is list of workers. diff --git a/plugins/http/tests/response_test.go b/plugins/http/tests/response_test.go index a526fe03..7901a0d1 100644 --- a/plugins/http/tests/response_test.go +++ b/plugins/http/tests/response_test.go @@ -6,7 +6,7 @@ import ( "net/http" "testing" - "github.com/spiral/roadrunner/v2/internal" + "github.com/spiral/roadrunner/v2/pkg/payload" http2 "github.com/spiral/roadrunner/v2/plugins/http" "github.com/stretchr/testify/assert" ) @@ -45,13 +45,13 @@ func (tw *testWriter) Push(target string, opts *http.PushOptions) error { } func TestNewResponse_Error(t *testing.T) { - r, err := http2.NewResponse(internal.Payload{Context: []byte(`invalid payload`)}) + r, err := http2.NewResponse(payload.Payload{Context: []byte(`invalid payload`)}) assert.Error(t, err) assert.Nil(t, r) } func TestNewResponse_Write(t *testing.T) { - r, err := http2.NewResponse(internal.Payload{ + r, err := http2.NewResponse(payload.Payload{ Context: []byte(`{"headers":{"key":["value"]},"status": 301}`), Body: []byte(`sample body`), }) @@ -68,7 +68,7 @@ func TestNewResponse_Write(t *testing.T) { } func TestNewResponse_Stream(t *testing.T) { - r, err := http2.NewResponse(internal.Payload{ + r, err := http2.NewResponse(payload.Payload{ Context: []byte(`{"headers":{"key":["value"]},"status": 301}`), }) @@ -92,7 +92,7 @@ func TestNewResponse_Stream(t *testing.T) { } func TestNewResponse_StreamError(t *testing.T) { - r, err := http2.NewResponse(internal.Payload{ + r, err := http2.NewResponse(payload.Payload{ Context: []byte(`{"headers":{"key":["value"]},"status": 301}`), }) @@ -112,7 +112,7 @@ func TestNewResponse_StreamError(t *testing.T) { } func TestWrite_HandlesPush(t *testing.T) { - r, err := http2.NewResponse(internal.Payload{ + r, err := http2.NewResponse(payload.Payload{ Context: []byte(`{"headers":{"Http2-Push":["/test.js"],"content-type":["text/html"]},"status": 200}`), }) @@ -127,7 +127,7 @@ func TestWrite_HandlesPush(t *testing.T) { } func TestWrite_HandlesTrailers(t *testing.T) { - r, err := http2.NewResponse(internal.Payload{ + r, err := http2.NewResponse(payload.Payload{ Context: []byte(`{"headers":{"Trailer":["foo, bar", "baz"],"foo":["test"],"bar":["demo"]},"status": 200}`), }) @@ -146,7 +146,7 @@ func TestWrite_HandlesTrailers(t *testing.T) { } func TestWrite_HandlesHandlesWhitespacesInTrailer(t *testing.T) { - r, err := http2.NewResponse(internal.Payload{ + r, err := http2.NewResponse(payload.Payload{ Context: []byte( `{"headers":{"Trailer":["foo\t,bar , baz"],"foo":["a"],"bar":["b"],"baz":["c"]},"status": 200}`), }) |