summaryrefslogtreecommitdiff
path: root/service/http
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-13 22:37:55 +0300
committerWolfy-J <[email protected]>2018-06-13 22:37:55 +0300
commit0cb81a72d49d5d3e1f8b8198b8228fdacc932236 (patch)
treeb6e599a177230eae32078e9f3f577637824b4648 /service/http
parent7b8724b181e6d11b6a8f367a64a3dc519aa1ee8b (diff)
size limit test
Diffstat (limited to 'service/http')
-rw-r--r--service/http/handler_test.go45
1 files changed, 45 insertions, 0 deletions
diff --git a/service/http/handler_test.go b/service/http/handler_test.go
index 6b44f1ec..d599b1d8 100644
--- a/service/http/handler_test.go
+++ b/service/http/handler_test.go
@@ -731,6 +731,51 @@ func TestServer_Error2(t *testing.T) {
assert.Equal(t, 500, r.StatusCode)
}
+func TestServer_Error3(t *testing.T) {
+ st := &Handler{
+ cfg: &Config{
+ MaxRequest: 1,
+ Uploads: &UploadsConfig{
+ Dir: os.TempDir(),
+ Forbid: []string{},
+ },
+ },
+ rr: roadrunner.NewServer(&roadrunner.ServerConfig{
+ Command: "php ../../php-src/tests/http/client.php pid pipes",
+ Relay: "pipes",
+ Pool: &roadrunner.Config{
+ NumWorkers: 1,
+ AllocateTimeout: 10000000,
+ DestroyTimeout: 10000000,
+ },
+ }),
+ }
+
+ assert.NoError(t, st.rr.Start())
+ defer st.rr.Stop()
+
+ hs := &http.Server{Addr: ":8077", Handler: st}
+ defer hs.Shutdown(context.Background())
+
+ go func() { hs.ListenAndServe() }()
+ time.Sleep(time.Millisecond * 10)
+
+ b2 := &bytes.Buffer{}
+ for i := 0; i < 1024*1024; i++ {
+ b2.Write([]byte(" "))
+ }
+
+ req, err := http.NewRequest("POST", "http://localhost"+hs.Addr, b2)
+ assert.NoError(t, err)
+
+ r, err := http.DefaultClient.Do(req)
+ assert.NoError(t, err)
+ defer r.Body.Close()
+
+ assert.NoError(t, err)
+ assert.Equal(t, 500, r.StatusCode)
+}
+
func BenchmarkHandler_Listen_Echo(b *testing.B) {
st := &Handler{
cfg: &Config{