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:net.anyflow.menton.http.HttpRequest.java
License:Apache License
public Map<String, List<String>> parameters() { if (parameters != null) { return parameters; }//from ww w.j a v a2s . c o m Map<String, List<String>> ret = Maps.newHashMap(); if (HttpMethod.GET.equals(method()) || HttpMethod.DELETE.equals(method())) { ret.putAll((new QueryStringDecoder(uri())).parameters()); return ret; } else if (headers().contains(HttpHeaderNames.CONTENT_TYPE) && headers().get(HttpHeaderNames.CONTENT_TYPE) .startsWith(HttpHeaderValues.APPLICATION_X_WWW_FORM_URLENCODED.toString()) && (HttpMethod.POST.equals(method()) || HttpMethod.PUT.equals(method()))) { ret.putAll((new QueryStringDecoder("/dummy?" + content().toString(CharsetUtil.UTF_8))).parameters()); } return ret; }
From source file:net.anyflow.menton.http.HttpRequest.java
License:Apache License
private void normalizeParameters() { String address = (new StringBuilder()).append(uriObject().getScheme()).append("://") .append(uriObject().getAuthority()).append(uriObject().getPath()).toString(); if (HttpMethod.GET.equals(method()) || HttpMethod.DELETE.equals(method())) { String parameters = convertParametersToString(); address += Strings.isNullOrEmpty(parameters) ? "" : "?" + parameters; } else if ((HttpMethod.POST.equals(method()) || HttpMethod.PUT.equals(method())) && (headers().contains(HttpHeaderNames.CONTENT_TYPE) == false || headers().get(HttpHeaderNames.CONTENT_TYPE) .startsWith(HttpHeaderValues.APPLICATION_X_WWW_FORM_URLENCODED.toString()))) { ByteBuf content = Unpooled.copiedBuffer(convertParametersToString(), CharsetUtil.UTF_8); headers().set(HttpHeaderNames.CONTENT_LENGTH, content.readableBytes()); content().clear();// ww w .ja v a 2 s .c om content().writeBytes(content); } setUri(address); }
From source file:org.apache.hyracks.control.cc.web.ApplicationInstallationHandler.java
License:Apache License
@Override public void handle(IServletRequest request, IServletResponse response) { String localPath = localPath(request); while (localPath.startsWith("/")) { localPath = localPath.substring(1); }// w w w . j a va 2s. com final String[] params = localPath.split("&"); if (params.length != 2 || params[0].isEmpty() || params[1].isEmpty()) { response.setStatus(HttpResponseStatus.BAD_REQUEST); return; } final String deployIdString = params[0]; final String fileName = params[1]; final String rootDir = ccs.getServerContext().getBaseDir().toString(); final String deploymentDir = rootDir.endsWith(File.separator) ? rootDir + "applications/" + deployIdString : rootDir + File.separator + "/applications/" + File.separator + deployIdString; final HttpMethod method = request.getHttpRequest().method(); try { response.setStatus(HttpResponseStatus.OK); if (method == HttpMethod.PUT) { final ByteBuf content = request.getHttpRequest().content(); writeToFile(content, deploymentDir, fileName); } else if (method == HttpMethod.GET) { readFromFile(fileName, deploymentDir, response); } else { response.setStatus(HttpResponseStatus.METHOD_NOT_ALLOWED); } } catch (Exception e) { LOGGER.log(Level.WARNING, "Unhandled exception ", e); response.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR); } }
From source file:org.apache.hyracks.http.server.AbstractServlet.java
License:Apache License
@Override public void handle(IServletRequest request, IServletResponse response) { try {//from w w w . j a v a 2s . c o m final HttpMethod method = request.getHttpRequest().method(); if (HttpMethod.GET.equals(method)) { get(request, response); } else if (HttpMethod.HEAD.equals(method)) { head(request, response); } else if (HttpMethod.POST.equals(method)) { post(request, response); } else if (HttpMethod.PUT.equals(method)) { put(request, response); } else if (HttpMethod.DELETE.equals(method)) { delete(request, response); } else if (HttpMethod.OPTIONS.equals(method)) { options(request, response); } else { notAllowed(method, response); } } catch (Exception e) { LOGGER.log(Level.WARNING, "Unhandled exception", e); response.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR); } catch (Throwable th) { //NOSONAR Just logging and then throwing again try { LOGGER.log(Level.WARNING, "Unhandled throwable", th); } catch (Throwable loggingFailure) {// NOSONAR... swallow logging failure } throw th; } }
From source file:org.apache.hyracks.http.server.AbstractServlet.java
License:Apache License
@SuppressWarnings("squid:S1172") protected void put(IServletRequest request, IServletResponse response) throws Exception { // designed to be extended but an error in standard case notAllowed(HttpMethod.PUT, response); }
From source file:org.asynchttpclient.Dsl.java
License:Open Source License
public static RequestBuilder put(String url) { return request(HttpMethod.PUT.name(), url); }
From source file:org.bridje.http.impl.HttpBridletRequestImpl.java
License:Apache License
@Override public boolean isPut() { return getMethod().equals(HttpMethod.PUT.name()); }
From source file:org.caratarse.auth.services.Routes.java
License:Apache License
public static void define(Configuration config, RestExpress server) { //TODO: Your routes here... server.uri("/populates.{format}", config.getPopulateController()).action("readAll", HttpMethod.GET) .action("deleteAll", HttpMethod.DELETE).name(Constants.Routes.POPULATE_COLLECTION); server.uri("/users/{userUuid}.{format}", config.getUserController()) .method(HttpMethod.GET, HttpMethod.PUT, HttpMethod.DELETE).name(Constants.Routes.USER_READ_ROUTE); server.uri("/users.{format}", config.getUserController()).action("readAll", HttpMethod.GET) .method(HttpMethod.POST).name(Constants.Routes.USER_COLLECTION_READ_ROUTE); server.uri("/users/{userUuid}/authorizations.{format}", config.getUserAuthorizationController()) .action("readAll", HttpMethod.GET).name(Constants.Routes.USER_AUTHORIZATIONS_ROUTE); server.uri("/users/{userUuid}/authorizations/{authorizationName}.{format}", config.getUserAuthorizationController()).method(HttpMethod.GET, HttpMethod.PUT, HttpMethod.DELETE) .action("addAuthorizationToUser", HttpMethod.POST).name(Constants.Routes.USER_AUTHORIZATION_ROUTE); //// or...// www. ja v a 2 s . c o m // server.regex("/some.regex", config.getRouteController()); }
From source file:org.elasticsearch.hadoop.http.netty4.Netty4HttpRequest.java
License:Apache License
@Override public Method method() { HttpMethod httpMethod = request.method(); if (httpMethod == HttpMethod.GET) return Method.GET; if (httpMethod == HttpMethod.POST) return Method.POST; if (httpMethod == HttpMethod.PUT) return Method.PUT; if (httpMethod == HttpMethod.DELETE) return Method.DELETE; if (httpMethod == HttpMethod.HEAD) { return Method.HEAD; }/*from w w w.ja v a 2s .c o m*/ if (httpMethod == HttpMethod.OPTIONS) { return Method.OPTIONS; } return Method.GET; }
From source file:org.elasticsearch.http.netty4.Netty4HttpClient.java
License:Apache License
@SafeVarargs // Safe not because it doesn't do anything with the type parameters but because it won't leak them into other methods. public final Collection<FullHttpResponse> put(SocketAddress remoteAddress, Tuple<String, CharSequence>... urisAndBodies) throws InterruptedException { return processRequestsWithBody(HttpMethod.PUT, remoteAddress, urisAndBodies); }