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


Java HttpMethod.GET属性代码示例

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


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

示例1: method

@Override
public Method method() {
    HttpMethod httpMethod = request.getMethod();
    if (httpMethod == HttpMethod.GET)
        return Method.GET;

    if (httpMethod == HttpMethod.POST)
        return Method.POST;

    if (httpMethod == HttpMethod.PUT)
        return Method.PUT;

    if (httpMethod == HttpMethod.DELETE)
        return Method.DELETE;

    if (httpMethod == HttpMethod.HEAD) {
        return Method.HEAD;
    }

    if (httpMethod == HttpMethod.OPTIONS) {
        return Method.OPTIONS;
    }

    return Method.GET;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:NettyHttpRequest.java

示例2: createMethod

/**
 * 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,代码行数:25,代码来源:NettyHttpHelper.java

示例3: channelConnected

@Override public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e)
    throws Exception {
  HttpRequest request =
      new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri.toString());
  request.addHeader(Names.ACCEPT, "text/event-stream");

  if (headers != null) {
    for (Map.Entry<String, String> entry : headers.entrySet()) {
      request.addHeader(entry.getKey(), entry.getValue());
    }
  }

  request.addHeader(Names.HOST, uri.getHost());
  request.addHeader(Names.ORIGIN, uri.getScheme() + "://" + uri.getHost());
  request.addHeader(Names.CACHE_CONTROL, "no-cache");
  if (lastEventId != null) {
    request.addHeader("Last-Event-ID", lastEventId);
  }
  e.getChannel().write(request);
  channel = e.getChannel();
}
 
开发者ID:tylerjroach,项目名称:eventsource-android,代码行数:21,代码来源:EventSourceChannelHandler.java

示例4: execute

@Override
public void execute(final TSDB tsdb, final HttpRpcPluginQuery query) throws IOException {
  // only accept GET/POST for now
  if (query.request().getMethod() != HttpMethod.GET && 
      query.request().getMethod() != HttpMethod.POST) {
    throw new BadRequestException(HttpResponseStatus.METHOD_NOT_ALLOWED, 
        "Method not allowed", "The HTTP method [" + query.method().getName() +
        "] is not permitted for this endpoint");
  }
  
  final String[] uri = query.explodePath();
  final String endpoint = uri.length > 1 ? uri[2].toLowerCase() : "";
  
  if ("version".equals(endpoint)) {
    handleVersion(query);
  } else if ("rate".equals(endpoint)) {
    handleRate(query);
  } else if ("namespace".equals(endpoint)) {
    handlePerNamespaceStats(query);
  } else if ("perthread".equals(endpoint)) {
    handlePerThreadStats(query);
  } else {
    throw new BadRequestException(HttpResponseStatus.NOT_IMPLEMENTED, 
        "Hello. You have reached an API that has been disconnected. "
        + "Please call again.");
  }
}
 
开发者ID:OpenTSDB,项目名称:opentsdb-rpc-kafka,代码行数:27,代码来源:KafkaHttpRpcPlugin.java

示例5: channelConnected

@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
  final String query = "/q?" + this.query.tsdbQueryParams();
  logger.debug("Sending query " + query);
  final DefaultHttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,
          query);
  e.getChannel().write(req);
}
 
开发者ID:yandex,项目名称:opentsdb-flume,代码行数:8,代码来源:LegacyHttpSource.java

示例6: stats

/**
 * WebSocket invoker for OpenTSDB HTTP <a href="http://opentsdb.net/docs/build/html/api_http/stats.html">api/stats</a> API call
 * @param request The JSONRequest
 */
@JSONRequestHandler(name="stats", description="Collects TSDB wide stats and returns them in JSON format to the caller")
public void stats(JSONRequest request) {
	try {
		HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/api/stats?json=true");
		invoke(false, httpRequest, request.response(ResponseType.RESP));
	} catch (Exception ex) {
		log.error("Failed to invoke stats", ex);
		request.error("Failed to invoke stats", ex).send();
	}
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:14,代码来源:TSDBJSONService.java

示例7: file

/**
 * WebSocket invoker for OpenTSDB HTTP <a href="http://opentsdb.net/docs/build/html/api_http/s.html">/s</a> static file retrieval API call
 * @param request The JSONRequest
 */
@JSONRequestHandler(name="s", description="Retrieves a static file")
public void file(JSONRequest request) {
	try {
		String fileName = request.getArgument("s").replace("\"", "");
		HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, ("/s/" + fileName));
		invokeForFile(httpRequest, request.response(ResponseType.RESP));
	} catch (Exception ex) {
		log.error("Failed to invoke s/file", ex);
		request.error("Failed to invoke s/file", ex).send();
	}
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:15,代码来源:TSDBJSONService.java

示例8: dropcaches

/**
 * WebSocket invoker for OpenTSDB HTTP <a href="http://opentsdb.net/docs/build/html/api_http/version.html">/s</a> OpenTSDB version info API call
 * @param request The JSONRequest
 */
@JSONRequestHandler(name="dropcaches", description="Drops all OpenTSDB server caches")
public void dropcaches(JSONRequest request) {
	try {
		HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/api/dropcaches?json=true");
		invoke(true, httpRequest, request.response(ResponseType.RESP));
	} catch (Exception ex) {
		log.error("Failed to invoke dropcaches", ex);
		request.error("Failed to invoke dropcaches", ex).send();
	}
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:14,代码来源:TSDBJSONService.java

示例9: logs

/**
 * WebSocket invoker for OpenTSDB HTTP <a href="http://opentsdb.net/docs/build/html/api_http/logs.html">/s</a> logs API call
 * @param request The JSONRequest
 */
@JSONRequestHandler(name="logs", description="Returns JSONized OpenTSDB log file entries")
public void logs(JSONRequest request) {
	try {
		HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/logs?json=true");
		invoke(true, httpRequest, request.response(ResponseType.RESP));
	} catch (Exception ex) {
		log.error("Failed to invoke logs", ex);
		request.error("Failed to invoke logs", ex).send();
	}
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:14,代码来源:TSDBJSONService.java

示例10: version

/**
 * WebSocket invoker for OpenTSDB HTTP <a href="http://opentsdb.net/docs/build/html/api_http/dropcaches.html">/s</a> drop caches API call
 * @param request The JSONRequest
 */
@JSONRequestHandler(name="version", description="Retrieves the OpenTSDB version info")
public void version(JSONRequest request) {
	try {
		HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/api/version?json=true");
		invoke(true, httpRequest, request.response(ResponseType.RESP));
	} catch (Exception ex) {
		log.error("Failed to invoke version", ex);
		request.error("Failed to invoke version", ex).send();
	}
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:14,代码来源:TSDBJSONService.java

示例11: aggregators

/**
 * WebSocket invoker for OpenTSDB HTTP <a href="http://opentsdb.net/docs/build/html/api_http/dropcaches.html">/s</a> aggregators API call
 * @param request The JSONRequest
 */
@JSONRequestHandler(name="aggregators", description="Retrieves the OpenTSDB available aggregator names")
public void aggregators(JSONRequest request) {
	try {
		HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/api/aggregators?json=true");
		invoke(false, httpRequest, request.response(ResponseType.RESP));
	} catch (Exception ex) {
		log.error("Failed to invoke aggregators", ex);
		request.error("Failed to invoke aggregators", ex).send();
	}
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:14,代码来源:TSDBJSONService.java

示例12: config

/**
 * WebSocket invoker for OpenTSDB HTTP <a href="http://opentsdb.net/docs/build/html/api_http/config.html">/s</a> config API call
 * @param request The JSONRequest
 */
@JSONRequestHandler(name="config", description="Retrieves the OpenTSDB configuration")
public void config(JSONRequest request) {
	try {
		HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/api/config?json=true");
		invoke(true, httpRequest, request.response(ResponseType.RESP));
	} catch (Exception ex) {
		log.error("Failed to invoke config", ex);
		request.error("Failed to invoke config", ex).send();
	}
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:14,代码来源:TSDBJSONService.java

示例13: ActionRequest

public ActionRequest(String uri, HttpRequest request) {
	this.uri = uri;
	this.request = request;

	if (request != null) {
		if (request.getMethod() == HttpMethod.GET) {
			// logger.debug("URI:{} , {}, {}", request.getUri(), request.getUri().length(), uri.length());
			if (request.getUri().length() > uri.length()) {
				queryString = request.getUri().substring(uri.length() + 1); // 맨앞의 ?를 제거하기 위해 +1
			}
		} else if (request.getMethod() == HttpMethod.POST) {
			long len = HttpHeaders.getContentLength(request);
			ChannelBuffer buffer = request.getContent();
			queryString = new String(buffer.toByteBuffer().array(), 0, (int) len);
		} else {

		}
		if(logger.isDebugEnabled()) {
			String debugQueryString = null;
			if(queryString != null) {
				debugQueryString = queryString.length() > 100 ? queryString.substring(0, 100) + "..." : queryString;
			}
			logger.debug("action {}, param={}", uri, debugQueryString);
		}

		parameterMap = new HashMap<String, String>();
		if (queryString != null) {
			parse();
		}
	}
}
 
开发者ID:gncloud,项目名称:fastcatsearch,代码行数:31,代码来源:ActionRequest.java

示例14: addChunkHandlesExistingChunkList

@Test
public void addChunkHandlesExistingChunkList() {
    DefaultLocalClientChannelFactory channelFactory = new DefaultLocalClientChannelFactory();
    DefaultChannelPipeline pipeline = new DefaultChannelPipeline();
    Channel channel = channelFactory.newChannel(pipeline);
    HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "");
    chunkedRequestAssembler.setup(channel, httpRequest);
    chunkedRequestAssembler.addChunk(channel, EMPTY_CHUNK);
}
 
开发者ID:graylog-labs,项目名称:jersey-netty,代码行数:9,代码来源:ChunkedRequestAssemblerTest.java

示例15: ActionRequest

public ActionRequest(String uri, HttpRequest request) {
		this.uri = uri;
		this.request = request;
        String contentType = request.getHeader("Content-Type");
		if (request != null) {
            parameterMap = new HashMap<String, String>();
			if (request.getMethod() == HttpMethod.GET) {
				// logger.debug("URI:{} , {}, {}", request.getUri(), request.getUri().length(), uri.length());
				if (request.getUri().length() > uri.length()) {
					queryString = request.getUri().substring(uri.length() + 1); // 맨앞의 ?를 제거하기 위해 +1
                    if (queryString != null) {
                        parse();
                    }
				}
			} else if (request.getMethod() == HttpMethod.POST || request.getMethod() == HttpMethod.PUT || request.getMethod() == HttpMethod.DELETE ) {
                if (request.getUri().length() > uri.length()) {
                    queryString = request.getUri().substring(uri.length() + 1); // 맨앞의 ?를 제거하기 위해 +1
                    if (queryString != null) {
                        parse();
                    }
                }
				long len = HttpHeaders.getContentLength(request);
				ChannelBuffer buffer = request.getContent();
				requestBody = new String(buffer.toByteBuffer().array(), 0, (int) len);
                if(contentType == null || !contentType.startsWith("text/plain")) {
                    if (requestBody != null) {
                        parse(requestBody);
                    }
                }
			} else {

			}
			if(logger.isDebugEnabled()) {
				String debugQueryString = null;
				if(queryString != null) {
					debugQueryString = queryString.length() > 100 ? queryString.substring(0, 100) + "..." : queryString;
				}
				logger.debug("action {}, param={}", uri, debugQueryString);
			}

//            parameterMap = new HashMap<String, String>();
//			if (queryString != null) {
//				parse();
//			}
		}
	}
 
开发者ID:gncloud,项目名称:fastcatsearch3,代码行数:46,代码来源:ActionRequest.java


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