当前位置: 首页>>代码示例>>Java>>正文


Java QueryStringDecoder.getParameters方法代码示例

本文整理汇总了Java中org.jboss.netty.handler.codec.http.QueryStringDecoder.getParameters方法的典型用法代码示例。如果您正苦于以下问题:Java QueryStringDecoder.getParameters方法的具体用法?Java QueryStringDecoder.getParameters怎么用?Java QueryStringDecoder.getParameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.netty.handler.codec.http.QueryStringDecoder的用法示例。


在下文中一共展示了QueryStringDecoder.getParameters方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseQueryParameters

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入方法依赖的package包/类
private QueryParams parseQueryParameters(QueryStringDecoder decoded) {
  final Map<String, List<String>> parameters = decoded.getParameters();
  return new QueryParams(
          safeOneValue(parameters, "type"),
          safeOneValue(parameters, "key"),
          Long.parseLong(safeOneValue(parameters, "from")),
          Long.parseLong(safeOneValue(parameters, "to"))
  );
}
 
开发者ID:yandex,项目名称:opentsdb-flume,代码行数:10,代码来源:LegacyHttpSource.java

示例2: apply

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入方法依赖的package包/类
public Future<HttpResponse> apply(HttpRequest req) {
    // Parse URL parameters
    String bannerSize = null;
    String opt = null;
    QueryStringDecoder decoder = new QueryStringDecoder(req.getUri());
    Map <String, List<String>> params = decoder.getParameters();
    if (params.containsKey("bsize")) {
        bannerSize = params.get("bsize").get(0);
        opt = params.get("opt").get(0);
    }

    // Parse cookie
    Cookie cookie = null;
    String value = req.getHeader("Cookie");
    if (value != null) {
        Set<Cookie> cookies = new CookieDecoder().decode(value);
        for (Cookie c : cookies) {
            if (c.getName().equals(COOKIE_NAME)) {
                cookie = c;
            }
        }
    }
    String vizid = null;
    if (cookie != null) {
        vizid = cookie.getValue();
    } else {
        vizid = UUID.randomUUID().toString();
        // TODO Skip cache access
    }

    // Get data from redis cache
    Future<scala.collection.immutable.Set<ChannelBuffer>> udResponse = redisCache.sMembers(vizid);

    Future<HttpResponse> response = udResponse.flatMap(new ProcessResponse(req, vizid, 
            bannerSize, opt, redisCache));
    System.out.println("[CookieServer] Returning response Future");
    return response;
}
 
开发者ID:eternalthinker,项目名称:finagle-6.x-java-example,代码行数:39,代码来源:CookieServerSingle.java

示例3: handle

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入方法依赖的package包/类
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);
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:11,代码来源:ParamsService.java

示例4: getOp

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入方法依赖的package包/类
private static String getOp(QueryStringDecoder decoder) {
  Map<String, List<String>> parameters = decoder.getParameters();
  return parameters.containsKey("op")
          ? parameters.get("op").get(0).toUpperCase() : null;
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:6,代码来源:FSImageHandler.java

示例5: messageReceived

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入方法依赖的package包/类
@Override
public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent e) throws Exception {

	// TODO create a security handeler to catch too long request
	// TODO handle file content type
	// TODO request and cookie
	// could be used to upload png etc

	if (readingChunks == false) {

		this.worksRequest = (WorksRequest) e.getMessage();

		if (is100ContinueExpected(worksRequest)) {
			send100Continue(e);
		}

		// important the buff is reused along the new requests instead
		strBuff.setLength(0);

		// TODO may consider a thread safe pool of queryStringdecoder.
		//
		QueryStringDecoder queryStringDecoder = new QueryStringDecoder(worksRequest.getUri());
		Map<String, List<String>> params = queryStringDecoder.getParameters();

		worksRequest.setParams(params);

		if (worksRequest.isChunked()) {
			readingChunks = true;
		} else {
			ChannelBuffer channelbufferContent = worksRequest.getContent();
			if (channelbufferContent.readable()) {
				// TODO here handle files
				// InputStream contentInputStream = null;
				// ByteArrayOutputStream out = new ByteArrayOutputStream();
				// IOUtils.copy(new
				// ChannelBufferInputStream(channelbufferContent), out);
				// byte[] n = out.toByteArray();
				// contentInputStream = new ByteArrayInputStream(n);

				// TODO here handle content type and uft8 see the RFC
				worksRequest.setContent(channelbufferContent);

			}

			writeResponse(e);
		}
	} else {
		l.warn("Chunked content not yet supported");
		HttpChunk chunk = (HttpChunk) e.getMessage();
		if (chunk.isLast()) {
			readingChunks = false;
		}
	}
}
 
开发者ID:mirasworks,项目名称:works,代码行数:55,代码来源:ServerHandler.java

示例6: apply

import org.jboss.netty.handler.codec.http.QueryStringDecoder; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Future<HttpResponse> apply(HttpRequest req) {
    // Parse URL parameters
    String bannerSize = null;
    String opt = null;
    QueryStringDecoder decoder = new QueryStringDecoder(req.getUri());
    Map <String, List<String>> params = decoder.getParameters();
    if (params.containsKey("bsize")) {
        bannerSize = params.get("bsize").get(0);
        opt = params.get("opt").get(0);
    }

    // Parse cookie
    Cookie cookie = null;
    String value = req.getHeader("Cookie");
    if (value != null) {
        Set<Cookie> cookies = new CookieDecoder().decode(value);
        for (Cookie c : cookies) {
            if (c.getName().equals(COOKIE_NAME)) {
                cookie = c;
            }
        }
    }
    String vizid = null;
    if (cookie != null) {
        vizid = cookie.getValue();
    } else {
        vizid = UUID.randomUUID().toString();
        // TODO Avoid cache access
    }

    // Get data from redis cache, through RedisServer
    Service<HttpRequest, HttpResponse> client = Http.newService(":8002");
    HttpRequest helperRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/");
    JSONObject jsonReq = new JSONObject();
    jsonReq.put("key", vizid);
    jsonReq.put("command", "SMEMBERS");
    ChannelBuffer buffer = ChannelBuffers.copiedBuffer(jsonReq.toJSONString(), UTF_8);
    helperRequest.setContent(buffer);
    helperRequest.setHeader(HttpHeaders.Names.CONTENT_TYPE, "application/json; charset=UTF-8");
    helperRequest.setHeader(HttpHeaders.Names.CONTENT_LENGTH, buffer.readableBytes());
    Future<HttpResponse> helperResponse = client.apply(helperRequest);
    client.close();

    Future<HttpResponse> response = helperResponse.flatMap(new ProcessResponse2(req, vizid, 
            bannerSize, opt, jsonParser));
    System.out.println("[CookieServer] Returning response Future");
    return response;
}
 
开发者ID:eternalthinker,项目名称:finagle-6.x-java-example,代码行数:50,代码来源:CookieServer.java


注:本文中的org.jboss.netty.handler.codec.http.QueryStringDecoder.getParameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。