Java Code Examples for org.jboss.netty.handler.codec.http.HttpMethod#POST
The following examples show how to use
org.jboss.netty.handler.codec.http.HttpMethod#POST .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NettyHttpRequest.java From Elasticsearch with Apache License 2.0 | 6 votes |
@Override public Method method() { HttpMethod httpMethod = request.getMethod(); 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; } if (httpMethod == HttpMethod.OPTIONS) { return Method.OPTIONS; } return Method.GET; }
Example 2
Source File: HttpServerRequestHandler.java From feeyo-hlsserver with Apache License 2.0 | 5 votes |
private void registerHandler(HttpMethod method, String path, IRequestHandler handler) { if (method == HttpMethod.GET) { getHandlers.insert(path, handler); } else if (method == HttpMethod.POST) { postHandlers.insert(path, handler); } else { throw new RuntimeException("HttpMethod is not supported"); } }
Example 3
Source File: KafkaHttpRpcPlugin.java From opentsdb-rpc-kafka with Apache License 2.0 | 5 votes |
@Override public void execute(final TSDB tsdb, final HttpRpcPluginQuery query) throws IOException { // only accept GET/POST for now if (query.request().getMethod() != HttpMethod.GET && query.request().getMethod() != HttpMethod.POST) { throw new BadRequestException(HttpResponseStatus.METHOD_NOT_ALLOWED, "Method not allowed", "The HTTP method [" + query.method().getName() + "] is not permitted for this endpoint"); } final String[] uri = query.explodePath(); final String endpoint = uri.length > 1 ? uri[2].toLowerCase() : ""; if ("version".equals(endpoint)) { handleVersion(query); } else if ("rate".equals(endpoint)) { handleRate(query); } else if ("namespace".equals(endpoint)) { handlePerNamespaceStats(query); } else if ("perthread".equals(endpoint)) { handlePerThreadStats(query); } else { throw new BadRequestException(HttpResponseStatus.NOT_IMPLEMENTED, "Hello. You have reached an API that has been disconnected. " + "Please call again."); } }
Example 4
Source File: WrapFileClientHandler.java From netty-file-parent with Apache License 2.0 | 5 votes |
public WrapFileClientHandler(String host, URI uri, String userName, String pwd) { this.host = host; this.uri = uri; this.userName = userName; this.pwd = pwd; this.request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, uri.toASCIIString()); setHeaderDatas(); }
Example 5
Source File: HttpServerRequestHandler.java From feeyo-hlsserver with Apache License 2.0 | 4 votes |
private IRequestHandler getHandler(HttpRequest request) { IRequestHandler handler = null; //解析QueryString String uriString = request.getUri(); //获取Path String path = null; int pathEndPos = uriString.indexOf('?'); if (pathEndPos < 0) { path = uriString; } else { path = uriString.substring(0, pathEndPos); } // 获取参数 Map<String, String> parameters = new HashMap<String, String>(); if (uriString.startsWith("?")) { uriString = uriString.substring(1, uriString.length()); } String[] querys = uriString.split("&"); for (String query : querys) { String[] pair = query.split("="); if (pair.length == 2) { try { parameters.put(URLDecoder.decode(pair[0], "UTF8"), URLDecoder.decode(pair[1],"UTF8")); } catch (UnsupportedEncodingException e) { parameters.put(pair[0], pair[1]); } } } HttpMethod method = request.getMethod(); if (method == HttpMethod.GET) { handler = getHandlers.retrieve(path, parameters); } else if (method == HttpMethod.POST) { handler = postHandlers.retrieve(path, parameters); } return handler; }