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


Java Methods.POST属性代码示例

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


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

示例1: createMethod

/**
 * Creates the HttpMethod to use to call the remote server, often either its GET or POST.
 *
 * @param exchange the exchange
 * @return the created method
 * @throws URISyntaxException
 */
public static HttpString createMethod(Exchange exchange, UndertowEndpoint endpoint, boolean hasPayload) throws URISyntaxException {
    // is a query string provided in the endpoint URI or in a header (header
    // overrules endpoint)
    String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
    // We need also check the HTTP_URI header query part
    String uriString = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
    // resolve placeholders in uriString
    try {
        uriString = exchange.getContext().resolvePropertyPlaceholders(uriString);
    } catch (Exception e) {
        throw new RuntimeExchangeException("Cannot resolve property placeholders with uri: " + uriString, exchange, e);
    }
    if (uriString != null) {
        URI uri = new URI(uriString);
        queryString = uri.getQuery();
    }
    if (queryString == null) {
        queryString = endpoint.getHttpURI().getRawQuery();
    }

    // compute what method to use either GET or POST
    HttpString answer;
    String m = exchange.getIn().getHeader(Exchange.HTTP_METHOD, String.class);
    if (m != null) {
        // always use what end-user provides in a header
        answer = new HttpString(m);
    } else if (queryString != null) {
        // if a query string is provided then use GET
        answer = Methods.GET;
    } else {
        // fallback to POST if we have payload, otherwise GET
        answer = hasPayload ? Methods.POST : Methods.GET;
    }

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:43,代码来源:UndertowHelper.java


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