(t *testing.T)
| 3715 | } |
| 3716 | |
| 3717 | func TestServerTimeoutErrorWithCode(t *testing.T) { |
| 3718 | t.Parallel() |
| 3719 | |
| 3720 | s := &Server{ |
| 3721 | Handler: func(ctx *RequestCtx) { |
| 3722 | go func() { |
| 3723 | ctx.Success("aaa/bbb", []byte("xxxyyy")) |
| 3724 | }() |
| 3725 | ctx.TimeoutErrorWithCode("should be ignored", 234) |
| 3726 | ctx.TimeoutErrorWithCode("stolen ctx", StatusBadRequest) |
| 3727 | }, |
| 3728 | } |
| 3729 | |
| 3730 | rw := &readWriter{} |
| 3731 | rw.r.WriteString("GET /foo HTTP/1.1\r\nHost: google.com\r\n\r\n") |
| 3732 | rw.r.WriteString("GET /foo HTTP/1.1\r\nHost: google.com\r\n\r\n") |
| 3733 | |
| 3734 | if err := s.ServeConn(rw); err != nil { |
| 3735 | t.Fatalf("Unexpected error from serveConn: %v", err) |
| 3736 | } |
| 3737 | |
| 3738 | br := bufio.NewReader(&rw.w) |
| 3739 | verifyResponse(t, br, StatusBadRequest, string(defaultContentType), "stolen ctx") |
| 3740 | verifyResponse(t, br, StatusBadRequest, string(defaultContentType), "stolen ctx") |
| 3741 | |
| 3742 | data, err := io.ReadAll(br) |
| 3743 | if err != nil { |
| 3744 | t.Fatalf("Unexpected error when reading remaining data: %v", err) |
| 3745 | } |
| 3746 | if len(data) != 0 { |
| 3747 | t.Fatalf("Unexpected data read after the first response %q. Expecting %q", data, "") |
| 3748 | } |
| 3749 | } |
| 3750 | |
| 3751 | func TestServerTimeoutError(t *testing.T) { |
| 3752 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…