List of usage examples for io.netty.handler.codec.http HttpResponseStatus EXPECTATION_FAILED
HttpResponseStatus EXPECTATION_FAILED
To view the source code for io.netty.handler.codec.http HttpResponseStatus EXPECTATION_FAILED.
Click Source Link
From source file:org.ballerinalang.test.service.http.sample.ExpectContinueTestCase.java
License:Open Source License
@Test(description = "Test ignoring inbound payload with a 417 response for request with expect:100-continue header") public void test100ContinueNegative() { HttpClient httpClient = new HttpClient("localhost", servicePort); DefaultHttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/continue"); DefaultLastHttpContent reqPayload = new DefaultLastHttpContent( Unpooled.wrappedBuffer(TestUtils.LARGE_ENTITY.getBytes())); httpRequest.headers().set(HttpHeaderNames.CONTENT_LENGTH, TestUtils.LARGE_ENTITY.getBytes().length); httpRequest.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN); List<FullHttpResponse> responses = httpClient.sendExpectContinueRequest(httpRequest, reqPayload); Assert.assertFalse(httpClient.waitForChannelClose()); // 417 Expectation Failed response Assert.assertEquals(responses.get(0).status(), HttpResponseStatus.EXPECTATION_FAILED, "Response code mismatch"); int length = Integer.parseInt(responses.get(0).headers().get(HttpHeaderNames.CONTENT_LENGTH)); Assert.assertEquals(length, 26, "Content length mismatched"); String payload = responses.get(0).content().readCharSequence(length, Charset.defaultCharset()).toString(); Assert.assertEquals(payload, "Do not send me any payload", "Entity body mismatched"); // Actual response Assert.assertEquals(responses.size(), 1, "Multiple responses received when only a 417 response was expected"); }
From source file:org.elasticsearch.http.nio.NioHttpServerTransportTests.java
License:Apache License
/** * Test that {@link NioHttpServerTransport} responds to an unsupported expectation with a 417 status. * @throws InterruptedException if the client communication with the server is interrupted */// www . ja v a 2 s . co m public void testExpectUnsupportedExpectation() throws InterruptedException { runExpectHeaderTest(Settings.EMPTY, "chocolate=yummy", 0, HttpResponseStatus.EXPECTATION_FAILED); }
From source file:org.restnext.server.ServerHandler.java
License:Apache License
private HttpResponseStatus fromStatus(Response.Status status) { switch (status) { case OK:/* w w w . ja v a2 s .c om*/ return HttpResponseStatus.OK; case CREATED: return HttpResponseStatus.CREATED; case ACCEPTED: return HttpResponseStatus.ACCEPTED; case NO_CONTENT: return HttpResponseStatus.NO_CONTENT; case RESET_CONTENT: return HttpResponseStatus.RESET_CONTENT; case PARTIAL_CONTENT: return HttpResponseStatus.PARTIAL_CONTENT; case MOVED_PERMANENTLY: return HttpResponseStatus.MOVED_PERMANENTLY; case FOUND: return HttpResponseStatus.FOUND; case SEE_OTHER: return HttpResponseStatus.SEE_OTHER; case NOT_MODIFIED: return HttpResponseStatus.NOT_MODIFIED; case USE_PROXY: return HttpResponseStatus.USE_PROXY; case TEMPORARY_REDIRECT: return HttpResponseStatus.TEMPORARY_REDIRECT; case BAD_REQUEST: return HttpResponseStatus.BAD_REQUEST; case UNAUTHORIZED: return HttpResponseStatus.UNAUTHORIZED; case PAYMENT_REQUIRED: return HttpResponseStatus.PAYMENT_REQUIRED; case FORBIDDEN: return HttpResponseStatus.FORBIDDEN; case NOT_FOUND: return HttpResponseStatus.NOT_FOUND; case METHOD_NOT_ALLOWED: return HttpResponseStatus.METHOD_NOT_ALLOWED; case NOT_ACCEPTABLE: return HttpResponseStatus.NOT_ACCEPTABLE; case PROXY_AUTHENTICATION_REQUIRED: return HttpResponseStatus.PROXY_AUTHENTICATION_REQUIRED; case REQUEST_TIMEOUT: return HttpResponseStatus.REQUEST_TIMEOUT; case CONFLICT: return HttpResponseStatus.CONFLICT; case GONE: return HttpResponseStatus.GONE; case LENGTH_REQUIRED: return HttpResponseStatus.LENGTH_REQUIRED; case PRECONDITION_FAILED: return HttpResponseStatus.PRECONDITION_FAILED; case REQUEST_ENTITY_TOO_LARGE: return HttpResponseStatus.REQUEST_ENTITY_TOO_LARGE; case REQUEST_URI_TOO_LONG: return HttpResponseStatus.REQUEST_URI_TOO_LONG; case UNSUPPORTED_MEDIA_TYPE: return HttpResponseStatus.UNSUPPORTED_MEDIA_TYPE; case REQUESTED_RANGE_NOT_SATISFIABLE: return HttpResponseStatus.REQUESTED_RANGE_NOT_SATISFIABLE; case EXPECTATION_FAILED: return HttpResponseStatus.EXPECTATION_FAILED; case INTERNAL_SERVER_ERROR: return HttpResponseStatus.INTERNAL_SERVER_ERROR; case NOT_IMPLEMENTED: return HttpResponseStatus.NOT_IMPLEMENTED; case BAD_GATEWAY: return HttpResponseStatus.BAD_GATEWAY; case SERVICE_UNAVAILABLE: return HttpResponseStatus.SERVICE_UNAVAILABLE; case GATEWAY_TIMEOUT: return HttpResponseStatus.GATEWAY_TIMEOUT; case HTTP_VERSION_NOT_SUPPORTED: return HttpResponseStatus.HTTP_VERSION_NOT_SUPPORTED; case CONTINUE: return HttpResponseStatus.CONTINUE; default: throw new RuntimeException(String.format("Status: %s not supported", status)); } }