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


Java HttpMethod.valueOf方法代码示例

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


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

示例1: createMethod

import org.jboss.netty.handler.codec.http.HttpMethod; //导入方法依赖的package包/类
/**
 * Creates the {@link HttpMethod} to use to call the remote server, often either its GET or POST.
 *
 * @param message  the Camel message
 * @return the created method
 */
public static HttpMethod createMethod(Message message, boolean hasPayload) {
    // use header first
    HttpMethod m = message.getHeader(Exchange.HTTP_METHOD, HttpMethod.class);
    if (m != null) {
        return m;
    }
    String name = message.getHeader(Exchange.HTTP_METHOD, String.class);
    if (name != null) {
        return HttpMethod.valueOf(name);
    }

    if (hasPayload) {
        // use POST if we have payload
        return HttpMethod.POST;
    } else {
        // fallback to GET
        return HttpMethod.GET;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:NettyHttpHelper.java

示例2: buildCorsConfig

import org.jboss.netty.handler.codec.http.HttpMethod; //导入方法依赖的package包/类
private CorsConfig buildCorsConfig(Settings settings) {
    if (settings.getAsBoolean(SETTING_CORS_ENABLED, false) == false) {
        return CorsConfigBuilder.forOrigins().disable().build();
    }
    String origin = settings.get(SETTING_CORS_ALLOW_ORIGIN);
    final CorsConfigBuilder builder;
    if (Strings.isNullOrEmpty(origin)) {
        builder = CorsConfigBuilder.forOrigins();
    } else if (origin.equals(ANY_ORIGIN)) {
        builder = CorsConfigBuilder.forAnyOrigin();
    } else {
        Pattern p = RestUtils.checkCorsSettingForRegex(origin);
        if (p == null) {
            builder = CorsConfigBuilder.forOrigins(RestUtils.corsSettingAsArray(origin));
        } else {
            builder = CorsConfigBuilder.forPattern(p);
        }
    }
    if (settings.getAsBoolean(SETTING_CORS_ALLOW_CREDENTIALS, false)) {
        builder.allowCredentials();
    }
    String[] strMethods = settings.getAsArray(SETTING_CORS_ALLOW_METHODS, DEFAULT_CORS_METHODS);
    HttpMethod[] methods = new HttpMethod[strMethods.length];
    for (int i = 0; i < methods.length; i++) {
        methods[i] = HttpMethod.valueOf(strMethods[i]);
    }
    return builder.allowedRequestMethods(methods)
                  .maxAge(settings.getAsInt(SETTING_CORS_MAX_AGE, DEFAULT_CORS_MAX_AGE))
                  .allowedRequestHeaders(settings.getAsArray(SETTING_CORS_ALLOW_HEADERS, DEFAULT_CORS_HEADERS))
                  .shortCircuit()
                  .build();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:33,代码来源:NettyHttpServerTransport.java

示例3: createMessage

import org.jboss.netty.handler.codec.http.HttpMethod; //导入方法依赖的package包/类
@Override
protected HttpMessage createMessage(String[] initialLine) throws Exception {

	WorksRequest httpRequest = new WorksRequest(HttpVersion.valueOf(initialLine[2]),
			HttpMethod.valueOf(initialLine[0]), initialLine[1]);
	return httpRequest;

}
 
开发者ID:mirasworks,项目名称:works,代码行数:9,代码来源:RequestDecoder.java

示例4: encode

import org.jboss.netty.handler.codec.http.HttpMethod; //导入方法依赖的package包/类
@Override
protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg)
        throws Exception
{
  RestRequest request = (RestRequest) msg;

  HttpMethod nettyMethod = HttpMethod.valueOf(request.getMethod());
  URL url = new URL(request.getURI().toString());
  String path = url.getFile();
  // RFC 2616, section 5.1.2:
  //   Note that the absolute path cannot be empty; if none is present in the original URI,
  //   it MUST be given as "/" (the server root).
  if (path.isEmpty())
  {
    path = "/";
  }

  HttpRequest nettyRequest =
      new DefaultHttpRequest(HttpVersion.HTTP_1_1, nettyMethod, path);

  nettyRequest.setHeader(HttpHeaders.Names.HOST, url.getAuthority());
  for (Map.Entry<String, String> e : request.getHeaders().entrySet())
  {
    nettyRequest.setHeader(e.getKey(), e.getValue());
  }

  final ByteString entity = request.getEntity();
  ChannelBuffer buf = ChannelBuffers.wrappedBuffer(entity.asByteBuffer());
  nettyRequest.setContent(buf);
  nettyRequest.setHeader(HttpHeaders.Names.CONTENT_LENGTH, entity.length());

  return nettyRequest;
}
 
开发者ID:ppdai,项目名称:rest4j,代码行数:34,代码来源:RAPClientCodec.java

示例5: getMethod

import org.jboss.netty.handler.codec.http.HttpMethod; //导入方法依赖的package包/类
/**
 * Returns the {@link HttpMethod} represented by the HTTP method header.
 */
public static HttpMethod getMethod(int spdyVersion, SpdyHeaderBlock block) {
    try {
        if (spdyVersion < 3) {
            return HttpMethod.valueOf(block.getHeader(Spdy2HttpNames.METHOD));
        } else {
            return HttpMethod.valueOf(block.getHeader(HttpNames.METHOD));
        }
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:jle,项目名称:andy,代码行数:15,代码来源:SpdyHeaders.java

示例6: getMethod

import org.jboss.netty.handler.codec.http.HttpMethod; //导入方法依赖的package包/类
@JsonIgnore
public HttpMethod getMethod() {
    return HttpMethod.valueOf(httpRequest.getMethod());
}
 
开发者ID:elasticsoftwarefoundation,项目名称:elasterix,代码行数:5,代码来源:ApiHttpMessage.java


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