Java Code Examples for io.netty.handler.codec.http.HttpMethod#name()
The following examples show how to use
io.netty.handler.codec.http.HttpMethod#name() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpUtil.java From InChat with Apache License 2.0 | 6 votes |
public static String checkType(FullHttpRequest msg){ msg.retain(); String url = msg.uri(); System.out.println(url); HttpMethod method = msg.method(); String meName = method.name(); if (url.equals(HttpConstant.URI_GET_SIZE) && meName.equals(HttpConstant.GET)){ return HttpConstant.GET_SIZE; }else if (url.equals(HttpConstant.URI_SEND_FROM_SERVER) && meName.equals(HttpConstant.POST)){ return HttpConstant.SEND_FROM_SERVER; }else if (url.equals(HttpConstant.URI_GET_LIST) && meName.equals(HttpConstant.GET)){ return HttpConstant.GET_LIST; }else if (url.equals(HttpConstant.URI_GET_STATE) && meName.equals(HttpConstant.POST)){ return HttpConstant.GET_STATE; }else if (url.equals(HttpConstant.URI_SEND_IN_CHAT) && meName.equals(HttpConstant.POST)){ return HttpConstant.SEND_IN_CHAT; }else { return HttpConstant.NOT_FIND_URI; } }
Example 2
Source File: RiposteWingtipsNettyClientTagAdapter.java From riposte with Apache License 2.0 | 5 votes |
@Nullable @Override public String getRequestHttpMethod(@Nullable HttpRequest request) { if (request == null) { return null; } HttpMethod method = request.method(); if (method == null) { return null; } return method.name(); }
Example 3
Source File: RiposteWingtipsServerTagAdapter.java From riposte with Apache License 2.0 | 5 votes |
@Nullable @Override public String getRequestHttpMethod(@Nullable RequestInfo<?> request) { if (request == null) { return null; } HttpMethod method = request.getMethod(); if (method == null) { return null; } return method.name(); }
Example 4
Source File: StreamingAsyncHttpClient.java From riposte with Apache License 2.0 | 5 votes |
protected @NotNull String getFallbackSpanName(@NotNull HttpRequest downstreamRequest) { try { HttpMethod method = downstreamRequest.method(); String methodName = (method == null) ? null : method.name(); return HttpRequestTracingUtils.getFallbackSpanNameForHttpRequest("async_downstream_call", methodName); } catch (Throwable t) { logger.error( "An unexpected error occurred while trying to extract fallback span name from Netty HttpRequest. " + "A hardcoded fallback name will be used as a last resort, however this error should be investigated " + "as it shouldn't be possible.", t ); return "async_downstream_call-UNKNOWN_HTTP_METHOD"; } }
Example 5
Source File: RiposteHandlerInternalUtil.java From riposte with Apache License 2.0 | 5 votes |
@NotNull String determineFallbackOverallRequestSpanName(@NotNull HttpRequest nettyRequest) { try { HttpMethod method = nettyRequest.method(); String methodName = (method == null) ? null : method.name(); return HttpRequestTracingUtils.getFallbackSpanNameForHttpRequest(null, methodName); } catch (Throwable t) { logger.error( "An unexpected error occurred while trying to extract fallback span name from Netty HttpRequest. " + "A hardcoded fallback name will be used as a last resort, however this error should be investigated " + "as it shouldn't be possible.", t ); return "UNKNOWN_HTTP_METHOD"; } }
Example 6
Source File: NettyRestHandler.java From turbo-rpc with Apache License 2.0 | 4 votes |
private String toString(FullHttpRequest httpRequest) { String uri = httpRequest.uri(); HttpMethod httpMethod = httpRequest.method(); return httpMethod.name() + " " + uri; }
Example 7
Source File: SignalFxEndpointMetricsHandlerTest.java From riposte with Apache License 2.0 | 4 votes |
@DataProvider(value = { "true | false | false", "false | true | false", "false | false | true", "true | true | true", }, splitBy = "\\|") @Test public void handleRequest_gracefully_handles_some_null_args( boolean endpointIsNull, boolean methodIsNull, boolean matchingPathTemplateIsNull ) { // given int statusCode = 242; int statusCodeXXValue = 2; long elapsedTimeMillis = 42; Endpoint endpoint = (endpointIsNull) ? null : endpointMock; doReturn(endpoint).when(httpStateMock).getEndpointForExecution(); String expectedEndpointClass = (endpointIsNull) ? "NONE" : endpoint.getClass().getName(); HttpMethod method = (methodIsNull) ? null : httpMethod; doReturn(method).when(requestInfoMock).getMethod(); String expectedMethodName = (methodIsNull) ? "NONE" : method.name(); String pathTemplate = (matchingPathTemplateIsNull) ? null : matchingPathTemplate; doReturn(pathTemplate).when(httpStateMock).getMatchingPathTemplate(); String expectedPathTemplate = (matchingPathTemplateIsNull) ? "NONE" : pathTemplate; // when handler.handleRequest( requestInfoMock, responseInfoMock, httpStateMock, statusCode, statusCodeXXValue, elapsedTimeMillis ); // then verify(metricMetadataMock).forBuilder(requestTimerBuilderMock); verify(dimensionConfiguratorMock).setupMetricWithDimensions( timerBuilderTaggerMock, requestInfoMock, responseInfoMock, httpStateMock, statusCode, statusCodeXXValue, elapsedTimeMillis, endpoint, expectedEndpointClass, expectedMethodName, expectedPathTemplate ); verify(timerBuilderTaggerMock).createOrGet(metricRegistryMock); verify(timerMock).update(elapsedTimeMillis, TimeUnit.MILLISECONDS); }
Example 8
Source File: VerifyDecoderFailedResultIsHandledTest.java From riposte with Apache License 2.0 | 4 votes |
private String generateUriForInitialLineLength(HttpMethod method, String baseUri, int desiredInitialLineLength) { String baseInitialLine = method.name() + " " + baseUri + "/ HTTP/1.1\r"; // Netty now considers the trailing \r when calculating header length. int neededWildcardLength = desiredInitialLineLength - baseInitialLine.length(); return baseUri + "/" + generatePayload(neededWildcardLength, "a"); }
Example 9
Source File: AsyncHttpClientHelper.java From riposte with Apache License 2.0 | 4 votes |
protected RequestBuilderWrapper generateRequestBuilderWrapper(String url, HttpMethod method, Optional<CircuitBreaker<Response>> customCircuitBreaker, boolean disableCircuitBreaker) { String httpMethod = method.name(); switch (httpMethod) { case "CONNECT": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.prepareConnect(url), customCircuitBreaker, disableCircuitBreaker); case "DELETE": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.prepareDelete(url), customCircuitBreaker, disableCircuitBreaker); case "GET": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.prepareGet(url), customCircuitBreaker, disableCircuitBreaker); case "HEAD": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.prepareHead(url), customCircuitBreaker, disableCircuitBreaker); case "POST": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.preparePost(url), customCircuitBreaker, disableCircuitBreaker); case "OPTIONS": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.prepareOptions(url), customCircuitBreaker, disableCircuitBreaker); case "PUT": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.preparePut(url), customCircuitBreaker, disableCircuitBreaker); case "PATCH": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.preparePatch(url), customCircuitBreaker, disableCircuitBreaker); case "TRACE": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.prepareTrace(url), customCircuitBreaker, disableCircuitBreaker); default: logger.warn( "The given method {} is not directly supported. We will try to force it anyway. The returned request builder may or may not work.", httpMethod); return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.preparePost(url).setMethod(httpMethod), customCircuitBreaker, disableCircuitBreaker); } }
Example 10
Source File: AsyncHttpClientHelper.java From riposte with Apache License 2.0 | 4 votes |
protected RequestBuilderWrapper generateRequestBuilderWrapper(String url, HttpMethod method, Optional<CircuitBreaker<Response>> customCircuitBreaker, boolean disableCircuitBreaker) { String httpMethod = method.name(); switch (httpMethod) { case "CONNECT": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.prepareConnect(url), customCircuitBreaker, disableCircuitBreaker); case "DELETE": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.prepareDelete(url), customCircuitBreaker, disableCircuitBreaker); case "GET": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.prepareGet(url), customCircuitBreaker, disableCircuitBreaker); case "HEAD": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.prepareHead(url), customCircuitBreaker, disableCircuitBreaker); case "POST": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.preparePost(url), customCircuitBreaker, disableCircuitBreaker); case "OPTIONS": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.prepareOptions(url), customCircuitBreaker, disableCircuitBreaker); case "PUT": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.preparePut(url), customCircuitBreaker, disableCircuitBreaker); case "PATCH": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.preparePatch(url), customCircuitBreaker, disableCircuitBreaker); case "TRACE": return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.prepareTrace(url), customCircuitBreaker, disableCircuitBreaker); default: logger.warn( "The given method {} is not directly supported. We will try to force it anyway. The returned request builder may or may not work.", httpMethod); return new RequestBuilderWrapper(url, httpMethod, asyncHttpClient.preparePost(url).setMethod(httpMethod), customCircuitBreaker, disableCircuitBreaker); } }