List of usage examples for io.netty.handler.codec.http HttpMethod POST
HttpMethod POST
To view the source code for io.netty.handler.codec.http HttpMethod POST.
Click Source Link
From source file:com.nike.cerberus.endpoints.authentication.AuthenticateIamPrincipalTest.java
License:Apache License
@Test public void requestMatcher_is_http_post() { final Collection<HttpMethod> httpMethods = subject.requestMatcher().matchingMethods(); assertThat(httpMethods).hasSize(1);/*from w ww . j a v a2 s . c o m*/ assertThat(httpMethods).contains(HttpMethod.POST); }
From source file:com.nike.cerberus.endpoints.authentication.AuthenticateIamRole.java
License:Apache License
@Override public Matcher requestMatcher() { return Matcher.match("/v1/auth/iam-role", HttpMethod.POST); }
From source file:com.nike.cerberus.endpoints.authentication.MfaCheck.java
License:Apache License
@Override public Matcher requestMatcher() { return Matcher.match("/v2/auth/mfa_check", HttpMethod.POST); }
From source file:com.nike.cerberus.endpoints.category.CreateCategory.java
License:Apache License
@Override public Matcher requestMatcher() { return Matcher.match(CATEGORY_PATH, HttpMethod.POST); }
From source file:com.nike.cerberus.endpoints.sdb.CreateSafeDepositBox.java
License:Apache License
@Override public Matcher requestMatcher() { return Matcher.match(BASE_PATH, HttpMethod.POST); }
From source file:com.phei.netty.nio.http.upload.HttpUploadClient.java
License:Apache License
/** * Multipart example//from ww w . j av a2s . com */ private static void formpostmultipart(Bootstrap bootstrap, String host, int port, URI uriFile, HttpDataFactory factory, List<Entry<String, String>> headers, List<InterfaceHttpData> bodylist) throws Exception { // XXX /formpostmultipart // Start the connection attempt. ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port)); // Wait until the connection attempt succeeds or fails. Channel channel = future.sync().channel(); // Prepare the HTTP request. HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, uriFile.toASCIIString()); // Use the PostBody encoder HttpPostRequestEncoder bodyRequestEncoder = new HttpPostRequestEncoder(factory, request, true); // true => multipart // it is legal to add directly header or cookie into the request until finalize for (Entry<String, String> entry : headers) { request.headers().set(entry.getKey(), entry.getValue()); } // add Form attribute from previous request in formpost() bodyRequestEncoder.setBodyHttpDatas(bodylist); // finalize request bodyRequestEncoder.finalizeRequest(); // send request channel.write(request); // test if request was chunked and if so, finish the write if (bodyRequestEncoder.isChunked()) { channel.write(bodyRequestEncoder); } channel.flush(); // Now no more use of file representation (and list of HttpData) bodyRequestEncoder.cleanFiles(); // Wait for the server to close the connection. channel.closeFuture().sync(); }
From source file:com.rackspacecloud.blueflood.http.QueryStringDecoderAndRouter.java
License:Apache License
@Override public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { // for POST requests, check Content-Type header if (request.getMethod() == HttpMethod.POST) { if (!mediaTypeChecker.isContentTypeValid(request.headers())) { DefaultHandler.sendErrorResponse(ctx, request, String.format("Unsupported media type for Content-Type: %s", request.headers().get(HttpHeaders.Names.CONTENT_TYPE)), HttpResponseStatus.UNSUPPORTED_MEDIA_TYPE); return; }//w w w . java2s . c o m } // for GET or POST requests, check Accept header if (request.getMethod() == HttpMethod.GET || request.getMethod() == HttpMethod.POST) { if (!mediaTypeChecker.isAcceptValid(request.headers())) { DefaultHandler.sendErrorResponse(ctx, request, String.format("Unsupported media type for Accept: %s", request.headers().get(HttpHeaders.Names.ACCEPT)), HttpResponseStatus.UNSUPPORTED_MEDIA_TYPE); return; } } router.route(ctx, HttpRequestWithDecodedQueryParams.create(request)); }
From source file:com.rackspacecloud.blueflood.http.RouteMatcher.java
License:Apache License
public void route(ChannelHandlerContext context, FullHttpRequest request) { final String method = request.getMethod().name(); final String URI = request.getUri(); // Method not implemented for any resource. So return 501. if (method == null || !implementedVerbs.contains(method)) { route(context, request, unsupportedVerbsHandler); return;//from w w w . j ava 2 s . c o m } final Pattern pattern = getMatchingPatternForURL(URI); // No methods registered for this pattern i.e. URL isn't registered. Return 404. if (pattern == null) { route(context, request, noRouteHandler); return; } final Set<String> supportedMethods = getSupportedMethods(pattern); if (supportedMethods == null) { log.warn("No supported methods registered for a known pattern " + pattern); route(context, request, noRouteHandler); return; } // The method requested is not available for the resource. Return 405. if (!supportedMethods.contains(method)) { route(context, request, unsupportedMethodHandler); return; } PatternRouteBinding binding = null; if (method.equals(HttpMethod.GET.name())) { binding = getBindings.get(pattern); } else if (method.equals(HttpMethod.PUT.name())) { binding = putBindings.get(pattern); } else if (method.equals(HttpMethod.POST.name())) { binding = postBindings.get(pattern); } else if (method.equals(HttpMethod.DELETE.name())) { binding = deleteBindings.get(pattern); } else if (method.equals(HttpMethod.PATCH.name())) { binding = deleteBindings.get(pattern); } else if (method.equals(HttpMethod.OPTIONS.name())) { binding = optionsBindings.get(pattern); } else if (method.equals(HttpMethod.HEAD.name())) { binding = headBindings.get(pattern); } else if (method.equals(HttpMethod.TRACE.name())) { binding = traceBindings.get(pattern); } else if (method.equals(HttpMethod.CONNECT.name())) { binding = connectBindings.get(pattern); } if (binding != null) { request = updateRequestHeaders(request, binding); route(context, request, binding.handler); } else { throw new RuntimeException("Cannot find a valid binding for URL " + URI); } }
From source file:com.rackspacecloud.blueflood.http.RouteMatcher.java
License:Apache License
public void post(String pattern, HttpRequestHandler handler) { addBinding(pattern, HttpMethod.POST.name(), handler, postBindings); }
From source file:com.rackspacecloud.blueflood.inputs.handlers.HttpEventsIngestionHandlerTest.java
License:Apache License
private FullHttpRequest createPutOneEventRequest(Map<String, Object> event) throws IOException { List<Map<String, Object>> events = new ArrayList<Map<String, Object>>(); events.add(event);// w w w. j a v a 2 s. c o m final String requestBody = new ObjectMapper().writeValueAsString(events.get(0)); return createRequest(HttpMethod.POST, "", requestBody); }