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


Java QueryStringDecoder.decodeComponent方法代码示例

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


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

示例1: decodePathTokens

import io.netty.handler.codec.http.QueryStringDecoder; //导入方法依赖的package包/类
private String[] decodePathTokens(String uri) {
    // Need to split the original URI (instead of QueryStringDecoder#path) then decode the tokens (components),
    // otherwise /test1/123%2F456 will not match /test1/:p1

    int qPos = uri.indexOf("?");
    String encodedPath = (qPos >= 0) ? uri.substring(0, qPos) : uri;

    String[] encodedTokens = PathPattern.removeSlashesAtBothEnds(encodedPath).split("/");

    String[] decodedTokens = new String[encodedTokens.length];
    for (int i = 0; i < encodedTokens.length; i++) {
        String encodedToken = encodedTokens[i];
        decodedTokens[i] = QueryStringDecoder.decodeComponent(encodedToken);
    }

    return decodedTokens;
}
 
开发者ID:all4you,项目名称:redant,代码行数:18,代码来源:Router.java

示例2: test

import io.netty.handler.codec.http.QueryStringDecoder; //导入方法依赖的package包/类
@Test
public void test() {
  System.out.println(new JsonArray().add("1").add(
          "$header.h1").encode());
  System.out.println(matchValue("devices/new/$param.param0/test/$param.param1", "[\\w./$]*([\\w$"
                                                                                + ".]+)"));
  String url = "devices/new/$param.param0/test/$param.param0";
  Pattern pattern = Pattern.compile("[\\w./]+([\\w$.]+)[\\w./]*");
  Matcher matcher = pattern.matcher(url);
  System.out.println(matcher.matches());
  if (matcher.matches()) {
    if (matcher.groupCount() > 0) {
      for (int i = 0; i < matcher.groupCount(); i++) {
        String group = matcher.group(i + 1);
        if (group != null) {
          final String k = "param" + i;
          final String value = QueryStringDecoder.decodeComponent(group.replace("+", "%2b"));
          System.out.println(value);
        }
      }
    }
  }
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:24,代码来源:UrlTest.java

示例3: matchValue

import io.netty.handler.codec.http.QueryStringDecoder; //导入方法依赖的package包/类
private List<String> matchValue(String baseString, String regex) {
  Pattern pattern = Pattern.compile(regex);
  Matcher matcher = pattern.matcher(baseString);
  List<String> matchValues = new ArrayList<>();
  if (matcher.matches()) {
    if (matcher.groupCount() > 0) {
      for (int i = 0; i < matcher.groupCount(); i++) {
        String group = matcher.group(i + 1);
        if (group != null) {
          final String value = QueryStringDecoder.decodeComponent(group.replace("+", "%2b"));
          matchValues.add(value);
        }
      }
    }
  }
  return matchValues;
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:18,代码来源:UrlTest.java

示例4: decodeAttribute

import io.netty.handler.codec.http.QueryStringDecoder; //导入方法依赖的package包/类
/**
 * Decode component
 *
 * @return the decoded component
 */
private static String decodeAttribute(String s, Charset charset) {
    try {
        return QueryStringDecoder.decodeComponent(s, charset);
    } catch (IllegalArgumentException e) {
        throw new ErrorDataDecoderException("Bad string: '" + s + '\'', e);
    }
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:13,代码来源:HttpPostStandardRequestDecoder.java

示例5: load

import io.netty.handler.codec.http.QueryStringDecoder; //导入方法依赖的package包/类
public void load(ChannelHandlerContext ctx, HttpRequest req) {
	this.method = req.getMethod();
	this.headers = req.headers();
	
       String value = req.headers().get(Names.COOKIE);

       if (StringUtil.isNotEmpty(value)) {
       	Set<Cookie> cset = ServerCookieDecoder.STRICT.decode(value);
       	
       	for (Cookie cookie : cset) 
       		this.cookies.put(cookie.name(), cookie);
       }
       
       QueryStringDecoder decoderQuery = new QueryStringDecoder(req.getUri());        
       this.parameters = decoderQuery.parameters();        // TODO decode
       this.path = new CommonPath(QueryStringDecoder.decodeComponent(decoderQuery.path()));
       this.orgpath = this.path;
       this.orgrequri = QueryStringDecoder.decodeComponent(decoderQuery.uri());
       
       this.contentType = new ContentTypeParser(this.headers.get(Names.CONTENT_TYPE));
       
   	if (Logger.isDebug()) {
   		Logger.debug("Request Method " + this.method);
   		
   		for (Entry<String, String> ent : this.headers.entries()) {
       		Logger.debug("Request header: " + ent.getKey() + ": " + ent.getValue());
   		}
   	}
}
 
开发者ID:Gadreel,项目名称:divconq,代码行数:30,代码来源:Request.java

示例6: MicroserviceHttpRequest

import io.netty.handler.codec.http.QueryStringDecoder; //导入方法依赖的package包/类
public MicroserviceHttpRequest(Request request, MultivaluedMap<String, ?> formParams, Object postParams) {

        this.msf4jRequest = request;
        this.method = request.getHttpMethod();
        this.isGetRequest = REQUEST_GET.equals(method);

        // process URI
        String rawUri = request.getUri();
        int uriPathEndIndex = rawUri.indexOf('?');
        String rawUriPath, rawQueryString;
        if (uriPathEndIndex == -1) {
            rawUriPath = rawUri;
            rawQueryString = null;
        } else {
            rawUriPath = rawUri.substring(0, uriPathEndIndex);
            rawQueryString = rawUri.substring(uriPathEndIndex + 1, rawUri.length());
        }
        this.uri = QueryStringDecoder.decodeComponent(rawUriPath);
        this.contextPath = HttpRequest.getContextPath(this.uri);
        this.uriWithoutContextPath = HttpRequest.getUriWithoutContextPath(this.uri);
        this.queryString = rawQueryString; // Query string is not very useful, so we don't bother to decode it.
        if (rawQueryString != null) {
            HashMap<String, Object> map = new HashMap<>();
            new QueryStringDecoder(rawQueryString, false).parameters()
                    .forEach((key, value) -> map.put(key, (value.size() == 1) ? value.get(0) : value));
            this.queryParams = map;
        } else {
            this.queryParams = Collections.emptyMap();
        }

        // process headers and cookies
        this.headers = new HashMap<>();
        request.getHeaders().getAll().forEach(header -> this.headers.put(header.getName(), header.getValue()));
        String cookieHeader = this.headers.get(HttpHeaders.COOKIE);
        this.cookies = (cookieHeader == null) ? Collections.emptyMap() :
                ServerCookieDecoder.STRICT.decode(cookieHeader).stream().collect(Collectors.toMap(Cookie::name,
                                                                                                  c -> c));

        // process POST data
        if (formParams == null) {
            // This request is not a form POST submission.
            this.files = Collections.emptyMap();
            if (postParams == null) {
                this.formParams = Collections.emptyMap();
            } else {
                if (postParams instanceof List) {
                    List<?> postParamsList = (List<?>) postParams;
                    this.formParams = new HashMap<>(postParamsList.size());
                    for (int i = 0; i < postParamsList.size(); i++) {
                        this.formParams.put(Integer.toString(i), postParamsList.get(i));
                    }
                } else if (postParams instanceof Map) {
                    this.formParams = (Map<String, Object>) postParams;
                } else {
                    throw new NotSupportedException(
                            "Unsupported JSON data type. Expected Map or List. Instead found '" +
                                    postParams.getClass().getName() + "'.");
                }
            }
        } else {
            this.formParams = new HashMap<>();
            this.files = new HashMap<>();
            for (Map.Entry<String, ? extends List<?>> entry : formParams.entrySet()) {
                List<?> values = entry.getValue();
                if (values.isEmpty()) {
                    continue;
                }
                if (values.get(0) instanceof File) {
                    this.files.put(entry.getKey(), (values.size() == 1) ? values.get(0) : values);
                } else {
                    this.formParams.put(entry.getKey(), (values.size() == 1) ? values.get(0) : values);
                }
            }
        }
    }
 
开发者ID:wso2-attic,项目名称:carbon-uuf,代码行数:76,代码来源:MicroserviceHttpRequest.java


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