@@ -553,6 +553,7 @@ func testRequestWithBody(t *testing.T, verb, path string) {
553553 testRequestWithBodyQueryParams ,
554554 testRequestWithBodyQueryParamsAndBody ,
555555 testRequestWithBodyBinaryBody ,
556+ testRequestWithBodyTransferEncoding ,
556557 }
557558 for _ , testFunc := range testFuncs {
558559 testFunc := testFunc
@@ -1030,6 +1031,45 @@ func testRequestWithBodyQueryParamsAndBody(t *testing.T, verb, path string) {
10301031 }
10311032}
10321033
1034+ func testRequestWithBodyTransferEncoding (t * testing.T , verb string , path string ) {
1035+ testCases := []struct {
1036+ given string
1037+ want string
1038+ }{
1039+ {"" , "" },
1040+ {"identity" , "" },
1041+ {"chunked" , "chunked" },
1042+ }
1043+ for _ , tc := range testCases {
1044+ tc := tc
1045+ t .Run ("transfer-encoding/" + tc .given , func (t * testing.T ) {
1046+ t .Parallel ()
1047+
1048+ srv := httptest .NewServer (app )
1049+ defer srv .Close ()
1050+
1051+ r , _ := http .NewRequest (verb , srv .URL + path , bytes .NewReader ([]byte ("{}" )))
1052+ if tc .given != "" {
1053+ r .TransferEncoding = []string {tc .given }
1054+ }
1055+
1056+ httpResp , err := srv .Client ().Do (r )
1057+ assertNilError (t , err )
1058+ assertIntEqual (t , httpResp .StatusCode , http .StatusOK )
1059+
1060+ var resp * bodyResponse
1061+ if err := json .NewDecoder (httpResp .Body ).Decode (& resp ); err != nil {
1062+ t .Fatalf ("failed to unmarshal body from JSON: %s" , err )
1063+ }
1064+
1065+ got := resp .Headers .Get ("Transfer-Encoding" )
1066+ if got != tc .want {
1067+ t .Errorf ("expected Transfer-Encoding %#v, got %#v" , tc .want , got )
1068+ }
1069+ })
1070+ }
1071+ }
1072+
10331073// TODO: implement and test more complex /status endpoint
10341074func TestStatus (t * testing.T ) {
10351075 t .Parallel ()
0 commit comments