|
34 | 34 | import static org.mockito.Mockito.timeout; |
35 | 35 | import static org.mockito.Mockito.verify; |
36 | 36 |
|
| 37 | +import com.google.common.collect.Lists; |
37 | 38 | import com.google.common.io.ByteStreams; |
38 | 39 | import io.grpc.Attributes; |
39 | 40 | import io.grpc.InternalChannelz.SocketStats; |
|
62 | 63 | import java.util.ArrayDeque; |
63 | 64 | import java.util.ArrayList; |
64 | 65 | import java.util.Arrays; |
| 66 | +import java.util.Collections; |
65 | 67 | import java.util.Deque; |
66 | 68 | import java.util.List; |
67 | 69 | import java.util.concurrent.CountDownLatch; |
@@ -919,8 +921,9 @@ public void httpGet_failsWith405() throws Exception { |
919 | 921 | CONTENT_TYPE_HEADER, |
920 | 922 | TE_HEADER)); |
921 | 923 | clientFrameWriter.flush(); |
922 | | - |
923 | | - verifyHttpError(1, 405, Status.Code.INTERNAL, "HTTP Method is not supported: GET"); |
| 924 | + List<Header> extraHeaders = Lists.newArrayList(new Header("allow", "POST")); |
| 925 | + verifyHttpError(1, 405, Status.Code.INTERNAL, "HTTP Method is not supported: GET", |
| 926 | + extraHeaders); |
924 | 927 |
|
925 | 928 | shutdownAndTerminate(/*lastStreamId=*/ 1); |
926 | 929 | } |
@@ -976,7 +979,8 @@ public void httpErrorsAdhereToFlowControl() throws Exception { |
976 | 979 | new Header(":status", "405"), |
977 | 980 | new Header("content-type", "text/plain; charset=utf-8"), |
978 | 981 | new Header("grpc-status", "" + Status.Code.INTERNAL.value()), |
979 | | - new Header("grpc-message", errorDescription)); |
| 982 | + new Header("grpc-message", errorDescription), |
| 983 | + new Header("allow", "POST")); |
980 | 984 | assertThat(clientFrameReader.nextFrame(clientFramesRead)).isTrue(); |
981 | 985 | verify(clientFramesRead) |
982 | 986 | .headers(false, false, 1, -1, responseHeaders, HeadersMode.HTTP_20_HEADERS); |
@@ -1398,11 +1402,18 @@ private void pingPong() throws IOException { |
1398 | 1402 |
|
1399 | 1403 | private void verifyHttpError( |
1400 | 1404 | int streamId, int httpCode, Status.Code grpcCode, String errorDescription) throws Exception { |
1401 | | - List<Header> responseHeaders = Arrays.asList( |
| 1405 | + verifyHttpError(streamId, httpCode, grpcCode, errorDescription, Collections.emptyList()); |
| 1406 | + } |
| 1407 | + |
| 1408 | + private void verifyHttpError( |
| 1409 | + int streamId, int httpCode, Status.Code grpcCode, String errorDescription, |
| 1410 | + List<Header> extraHeaders) throws Exception { |
| 1411 | + List<Header> responseHeaders = Lists.newArrayList( |
1402 | 1412 | new Header(":status", "" + httpCode), |
1403 | 1413 | new Header("content-type", "text/plain; charset=utf-8"), |
1404 | 1414 | new Header("grpc-status", "" + grpcCode.value()), |
1405 | 1415 | new Header("grpc-message", errorDescription)); |
| 1416 | + responseHeaders.addAll(extraHeaders); |
1406 | 1417 | assertThat(clientFrameReader.nextFrame(clientFramesRead)).isTrue(); |
1407 | 1418 | verify(clientFramesRead) |
1408 | 1419 | .headers(false, false, streamId, -1, responseHeaders, HeadersMode.HTTP_20_HEADERS); |
|
0 commit comments