Java Code Examples for org.jboss.netty.handler.codec.http.HttpRequest#getUri()
The following examples show how to use
org.jboss.netty.handler.codec.http.HttpRequest#getUri() .
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: HttpServerHandler.java From glowroot with Apache License 2.0 | 6 votes |
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { if (!readingChunks) { request = (HttpRequest) e.getMessage(); String uri = request.getUri(); if (uri.equals("/exception")) { throw new Exception("Test"); } if (request.isChunked()) { readingChunks = true; } else { writeResponse(e); } } else { HttpChunk chunk = (HttpChunk) e.getMessage(); if (chunk.isLast()) { readingChunks = false; writeResponse(e); } } }
Example 2
Source File: ParamsService.java From ob1k with Apache License 2.0 | 5 votes |
public ComposableFuture<Map<String, String>> handle(final HttpRequest request) { final QueryStringDecoder queryStringDecoder = new QueryStringDecoder(request.getUri()); final Map<String,List<String>> params = queryStringDecoder.getParameters(); final Map<String, String> res = new HashMap<>(); for (final String key: params.keySet()) { res.put(key, params.get(key).get(0)); } return ComposableFutures.fromValue(res); }
Example 3
Source File: WebSocketChannelHandler.java From usergrid with Apache License 2.0 | 5 votes |
private String getWebSocketLocation( HttpRequest req ) { String path = req.getUri(); if ( path.equals( "/" ) ) { path = null; } if ( path != null ) { path = removeEnd( path, "/" ); } String location = ( ssl ? "wss://" : "ws://" ) + req.getHeader( HttpHeaders.Names.HOST ) + ( path != null ? path : "" ); logger.info( location ); return location; }
Example 4
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; }
Example 5
Source File: InterDataRetriever.java From incubator-tajo with Apache License 2.0 | 4 votes |
@Override public FileChunk [] handle(ChannelHandlerContext ctx, HttpRequest request) throws IOException { int start = request.getUri().indexOf('?'); if (start < 0) { throw new IllegalArgumentException("Wrong request: " + request.getUri()); } String queryStr = request.getUri().substring(start + 1); LOG.info("QUERY: " + queryStr); String [] queries = queryStr.split("&"); String qid = null; String fn = null; String [] kv; for (String query : queries) { kv = query.split("="); if (kv[0].equals("qid")) { qid = kv[1]; } else if (kv[0].equals("fn")) { fn = kv[1]; } } String baseDir = map.get(qid); if (baseDir == null) { throw new FileNotFoundException("No such qid: " + qid); } File file = new File(baseDir + "/" + fn); if (file.isHidden() || !file.exists()) { throw new FileNotFoundException("No such file: " + baseDir + "/" + file.getName()); } if (!file.isFile()) { throw new FileAccessForbiddenException("No such file: " + baseDir + "/" + file.getName()); } return new FileChunk[] {new FileChunk(file, 0, file.length())}; }