本文整理汇总了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"))
);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
}
示例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;
}