List of usage examples for io.netty.handler.codec.http HttpMethod PUT
HttpMethod PUT
To view the source code for io.netty.handler.codec.http HttpMethod PUT.
Click Source Link
From source file:org.nosceon.titanite.HttpServerHandler.java
License:Apache License
private BodyParser newBodyParser(RoutingResult routing, HttpRequest request) { HttpMethod method = request.getMethod(); if (method.equals(HttpMethod.POST) || method.equals(HttpMethod.PUT) || method.equals(HttpMethod.PATCH)) { if (routing.bodyParser() != null) { BodyParser bp = routing.bodyParser().get(); if (bp != null) { return bp; }/* www .j a v a2 s .c o m*/ } String contentType = request.headers().get(HttpHeaders.Names.CONTENT_TYPE); if (contentType != null) { String lowerCaseContentType = contentType.toLowerCase(); boolean isURLEncoded = lowerCaseContentType .startsWith(HttpHeaders.Values.APPLICATION_X_WWW_FORM_URLENCODED); boolean isMultiPart = lowerCaseContentType.startsWith(HttpHeaders.Values.MULTIPART_FORM_DATA); if (isMultiPart) { return new FormParamsBodyParser(maxMultipartRequestSize); } if (isURLEncoded) { return new FormParamsBodyParser(maxRequestSize); } } return new RawBodyParser(maxRequestSize); } else { return new EmptyBodyParser(); } }
From source file:org.nosceon.titanite.MethodsTest.java
License:Apache License
@Test public void test() { given().expect().statusCode(200).body(equalTo(HttpMethod.GET.name())).when().get(uri("/resource")); given().expect().statusCode(200).body(equalTo(HttpMethod.POST.name())).when().post(uri("/resource")); given().expect().statusCode(200).body(equalTo(HttpMethod.PUT.name())).when().put(uri("/resource")); given().expect().statusCode(200).body(equalTo(HttpMethod.DELETE.name())).when().delete(uri("/resource")); given().expect().statusCode(200).body(equalTo(HttpMethod.PATCH.name())).when().patch(uri("/resource")); given().expect().statusCode(200).body(equalTo(HttpMethod.GET.name())).when().get(uri("/controller")); given().expect().statusCode(200).body(equalTo(HttpMethod.POST.name())).when().post(uri("/controller")); given().expect().statusCode(200).body(equalTo(HttpMethod.PUT.name())).when().put(uri("/controller")); given().expect().statusCode(200).body(equalTo(HttpMethod.DELETE.name())).when().delete(uri("/controller")); given().expect().statusCode(200).body(equalTo(HttpMethod.PATCH.name())).when().patch(uri("/controller")); }
From source file:org.restexpress.pipeline.JsendWrappedResponseTest.java
License:Apache License
@Test public void shouldWrapPutInJsendJson() { sendEvent(HttpMethod.PUT, "/normal_put.json", ""); assertEquals(1, observer.getReceivedCount()); assertEquals(1, observer.getCompleteCount()); assertEquals(1, observer.getSuccessCount()); assertEquals(0, observer.getExceptionCount()); // System.out.println(httpResponse.toString()); assertEquals("{\"code\":200,\"status\":\"success\",\"data\":\"Normal PUT action\"}", httpResponse.toString());//from w ww. ja v a 2 s. c o m }
From source file:org.restexpress.pipeline.JsendWrappedResponseTest.java
License:Apache License
@Test public void shouldWrapPutInJsendJsonUsingQueryString() { sendEvent(HttpMethod.PUT, "/normal_put?format=json", ""); assertEquals(1, observer.getReceivedCount()); assertEquals(1, observer.getCompleteCount()); assertEquals(1, observer.getSuccessCount()); assertEquals(0, observer.getExceptionCount()); // System.out.println(httpResponse.toString()); assertEquals("{\"code\":200,\"status\":\"success\",\"data\":\"Normal PUT action\"}", httpResponse.toString());/*from www . j a v a 2s . co m*/ }
From source file:org.restexpress.pipeline.JsendWrappedResponseTest.java
License:Apache License
@Test public void shouldWrapPutInJsendXml() { sendEvent(HttpMethod.PUT, "/normal_put.xml", ""); assertEquals(1, observer.getReceivedCount()); assertEquals(1, observer.getCompleteCount()); assertEquals(1, observer.getSuccessCount()); assertEquals(0, observer.getExceptionCount()); // System.out.println(httpResponse.toString()); assertTrue(httpResponse.toString().startsWith("<response>")); assertTrue(httpResponse.toString().contains("<code>200</code>")); assertTrue(httpResponse.toString().contains("<status>success</status>")); assertTrue(httpResponse.toString().contains("<data class=\"string\">Normal PUT action</data>")); assertTrue(httpResponse.toString().endsWith("</response>")); }
From source file:org.restexpress.pipeline.JsendWrappedResponseTest.java
License:Apache License
@Test public void shouldWrapPutInJsendXmlUsingQueryString() { sendEvent(HttpMethod.PUT, "/normal_put?format=xml", ""); assertEquals(1, observer.getReceivedCount()); assertEquals(1, observer.getCompleteCount()); assertEquals(1, observer.getSuccessCount()); assertEquals(0, observer.getExceptionCount()); // System.out.println(httpResponse.toString()); assertTrue(httpResponse.toString().startsWith("<response>")); assertTrue(httpResponse.toString().contains("<code>200</code>")); assertTrue(httpResponse.toString().contains("<status>success</status>")); assertTrue(httpResponse.toString().contains("<data class=\"string\">Normal PUT action</data>")); assertTrue(httpResponse.toString().endsWith("</response>")); }
From source file:org.restexpress.pipeline.RawWrappedResponseTest.java
License:Apache License
@Test public void shouldWrapPutInRawJson() { sendEvent(HttpMethod.PUT, "/normal_put.json", ""); assertEquals(1, observer.getReceivedCount()); assertEquals(1, observer.getCompleteCount()); assertEquals(1, observer.getSuccessCount()); assertEquals(0, observer.getExceptionCount()); // System.out.println(httpResponse.toString()); assertEquals("\"Normal PUT action\"", httpResponse.toString()); }
From source file:org.restexpress.pipeline.RawWrappedResponseTest.java
License:Apache License
@Test public void shouldWrapPutInRawJsonUsingQueryString() { sendEvent(HttpMethod.PUT, "/normal_put?format=json", ""); assertEquals(1, observer.getReceivedCount()); assertEquals(1, observer.getCompleteCount()); assertEquals(1, observer.getSuccessCount()); assertEquals(0, observer.getExceptionCount()); // System.out.println(httpResponse.toString()); assertEquals("\"Normal PUT action\"", httpResponse.toString()); }
From source file:org.restexpress.pipeline.RawWrappedResponseTest.java
License:Apache License
@Test public void shouldWrapPutInRawXml() { sendEvent(HttpMethod.PUT, "/normal_put.xml", ""); assertEquals(1, observer.getReceivedCount()); assertEquals(1, observer.getCompleteCount()); assertEquals(1, observer.getSuccessCount()); assertEquals(0, observer.getExceptionCount()); // System.out.println(httpResponse.toString()); assertEquals("<string>Normal PUT action</string>", httpResponse.toString()); }
From source file:org.restexpress.pipeline.RawWrappedResponseTest.java
License:Apache License
@Test public void shouldWrapPutInRawXmlUsingQueryString() { sendEvent(HttpMethod.PUT, "/normal_put?format=xml", ""); assertEquals(1, observer.getReceivedCount()); assertEquals(1, observer.getCompleteCount()); assertEquals(1, observer.getSuccessCount()); assertEquals(0, observer.getExceptionCount()); // System.out.println(httpResponse.toString()); assertEquals("<string>Normal PUT action</string>", httpResponse.toString()); }