diff options
Diffstat (limited to 'service/http')
-rw-r--r-- | service/http/config_test.go | 5 | ||||
-rw-r--r-- | service/http/handler_test.go | 8 | ||||
-rw-r--r-- | service/http/request.go | 5 | ||||
-rw-r--r-- | service/http/response.go | 3 | ||||
-rw-r--r-- | service/http/rpc_test.go | 5 | ||||
-rw-r--r-- | service/http/service_test.go | 6 | ||||
-rw-r--r-- | service/http/uploads.go | 3 | ||||
-rw-r--r-- | service/http/uploads_test.go | 3 |
8 files changed, 24 insertions, 14 deletions
diff --git a/service/http/config_test.go b/service/http/config_test.go index 79c81d2d..d95e0995 100644 --- a/service/http/config_test.go +++ b/service/http/config_test.go @@ -13,7 +13,10 @@ import ( type mockCfg struct{ cfg string } func (cfg *mockCfg) Get(name string) service.Config { return nil } -func (cfg *mockCfg) Unmarshal(out interface{}) error { return json.Unmarshal([]byte(cfg.cfg), out) } +func (cfg *mockCfg) Unmarshal(out interface{}) error { + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.cfg), out) +} func Test_Config_Hydrate_Error1(t *testing.T) { cfg := &mockCfg{`{"address": "localhost:8080"}`} diff --git a/service/http/handler_test.go b/service/http/handler_test.go index 994a663c..cb1cd728 100644 --- a/service/http/handler_test.go +++ b/service/http/handler_test.go @@ -644,7 +644,7 @@ func TestHandler_FormData_POST(t *testing.T) { t.Errorf("error listening the interface: error %v", err) } }() - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Millisecond * 500) form := url.Values{} @@ -860,7 +860,7 @@ func TestHandler_FormData_PUT(t *testing.T) { t.Errorf("error listening the interface: error %v", err) } }() - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Millisecond * 500) form := url.Values{} @@ -1124,7 +1124,7 @@ func TestHandler_Multipart_PUT(t *testing.T) { t.Errorf("error listening the interface: error %v", err) } }() - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Millisecond * 500) var mb bytes.Buffer w := multipart.NewWriter(&mb) @@ -1241,7 +1241,7 @@ func TestHandler_Multipart_PATCH(t *testing.T) { t.Errorf("error listening the interface: error %v", err) } }() - time.Sleep(time.Millisecond * 10) + time.Sleep(time.Millisecond * 500) var mb bytes.Buffer w := multipart.NewWriter(&mb) diff --git a/service/http/request.go b/service/http/request.go index d8bd4d30..acf80893 100644 --- a/service/http/request.go +++ b/service/http/request.go @@ -135,12 +135,13 @@ func (r *Request) Close(log *logrus.Logger) { func (r *Request) Payload() (p *roadrunner.Payload, err error) { p = &roadrunner.Payload{} - if p.Context, err = json.Marshal(r); err != nil { + j := json.ConfigCompatibleWithStandardLibrary + if p.Context, err = j.Marshal(r); err != nil { return nil, err } if r.Parsed { - if p.Body, err = json.Marshal(r.body); err != nil { + if p.Body, err = j.Marshal(r.body); err != nil { return nil, err } } else if r.body != nil { diff --git a/service/http/response.go b/service/http/response.go index 38ac4417..0942b3d2 100644 --- a/service/http/response.go +++ b/service/http/response.go @@ -24,7 +24,8 @@ type Response struct { // NewResponse creates new response based on given rr payload. func NewResponse(p *roadrunner.Payload) (*Response, error) { r := &Response{body: p.Body} - if err := json.Unmarshal(p.Context, r); err != nil { + j := json.ConfigCompatibleWithStandardLibrary + if err := j.Unmarshal(p.Context, r); err != nil { return nil, err } diff --git a/service/http/rpc_test.go b/service/http/rpc_test.go index 2874e8b0..9f56e2cd 100644 --- a/service/http/rpc_test.go +++ b/service/http/rpc_test.go @@ -93,10 +93,11 @@ func Test_RPC_Unix(t *testing.T) { c.Register(ID, &Service{}) sock := `unix://` + os.TempDir() + `/rpc.unix` - j, _ := json.Marshal(sock) + j := json.ConfigCompatibleWithStandardLibrary + data, _ := j.Marshal(sock) assert.NoError(t, c.Init(&testCfg{ - rpcCfg: `{"enable":true, "listen":` + string(j) + `}`, + rpcCfg: `{"enable":true, "listen":` + string(data) + `}`, httpCfg: `{ "enable": true, "address": ":6032", diff --git a/service/http/service_test.go b/service/http/service_test.go index 44aba576..53dbb3df 100644 --- a/service/http/service_test.go +++ b/service/http/service_test.go @@ -43,7 +43,8 @@ func (cfg *testCfg) Get(name string) service.Config { return nil } func (cfg *testCfg) Unmarshal(out interface{}) error { - return json.Unmarshal([]byte(cfg.target), out) + j := json.ConfigCompatibleWithStandardLibrary + return j.Unmarshal([]byte(cfg.target), out) } func Test_Service_NoConfig(t *testing.T) { @@ -554,7 +555,8 @@ func Test_Service_Error4(t *testing.T) { func tmpDir() string { p := os.TempDir() - r, _ := json.Marshal(p) + j := json.ConfigCompatibleWithStandardLibrary + r, _ := j.Marshal(p) return string(r) } diff --git a/service/http/uploads.go b/service/http/uploads.go index 15522503..39a9eaf2 100644 --- a/service/http/uploads.go +++ b/service/http/uploads.go @@ -42,7 +42,8 @@ type Uploads struct { // MarshalJSON marshal tree tree into JSON. func (u *Uploads) MarshalJSON() ([]byte, error) { - return json.Marshal(u.tree) + j := json.ConfigCompatibleWithStandardLibrary + return j.Marshal(u.tree) } // Open moves all uploaded files to temp directory, return error in case of issue with temp directory. File errors diff --git a/service/http/uploads_test.go b/service/http/uploads_test.go index f336951e..08177c72 100644 --- a/service/http/uploads_test.go +++ b/service/http/uploads_test.go @@ -424,7 +424,8 @@ func fileString(f string, errNo int, mime string) string { v.Size = 0 } - r, err := json.Marshal(v) + j := json.ConfigCompatibleWithStandardLibrary + r, err := j.Marshal(v) if err != nil { fmt.Println(fmt.Errorf("error marshalling fInfo, error: %v", err)) } |