Get the HTTP method associated with the given HTTP request

@param aHttpRequest
The http request to query. May not be <code>null</code>.
@return <code>null</code> if no supported HTTP method is contained
435972
@Nullable
  public static EHttpMethod getHttpMethod (@Nonnull final HttpServletRequest aHttpRequest)
  {
    ValueEnforcer.notNull (aHttpRequest, "HttpRequest");

    final String sMethod = aHttpRequest.getMethod ();
    return EHttpMethod.getFromNameOrNull (sMethod);
  }
262916
public BoundRequestBuilder createRequest()
            throws HttpRequestCreateException {
        BoundRequestBuilder builder = null;

        getLogger().debug("AHC completeUrl " + requestUrl);

        try {

            switch (httpMethod) {
            case GET:
                builder = client.prepareGet(requestUrl);
                break;
            case POST:
                builder = client.preparePost(requestUrl);
                break;
            case PUT:
                builder = client.preparePut(requestUrl);
                break;
            case HEAD:
                builder = client.prepareHead(requestUrl);
                break;
            case OPTIONS:
                builder = client.prepareOptions(requestUrl);
                break;
            case DELETE:
                builder = client.prepareDelete(requestUrl);
                break;
            default:
                break;
            }

            PcHttpUtils.addHeaders(builder, this.httpHeaderMap);
            if (!Strings.isNullOrEmpty(postData)) {
                builder.setBody(postData);
                String charset = "";
                if (null!=this.httpHeaderMap) {
                    charset = this.httpHeaderMap.get("charset");
                }
                if(!Strings.isNullOrEmpty(charset)) {
                    builder.setBodyEncoding(charset);
                }
            }

        } catch (Exception t) {
            throw new HttpRequestCreateException(
                    "Error in creating request in Httpworker. "
                            + " If BoundRequestBuilder is null. Then fail to create.",
                    t);
        }

        return builder;

    }
713922
public GetInstanceResponse getInstance(GetInstanceRequest request) {
        checkNotNull(request, "request should not be null.");
        checkNotNull(request.getInstanceId(), "request instanceId should not be null.");
        InternalRequest internalRequest = this.createRequest(
                request, HttpMethodName.GET, INSTANCE_PREFIX, request.getInstanceId());
        return this.invokeHttpClient(internalRequest, GetInstanceResponse.class);
    }
695234
public static String getRequestBody(HttpServletRequest request) {
		if(request.getMethod().equals("GET") || request.getMethod().equals("DELETE")) {
			return null;
		}
		
		StringBuilder stringBuilder = new StringBuilder();
		BufferedReader bufferedReader = null;
		try {
			InputStream inputStream = request.getInputStream();
			if (inputStream != null) {
				bufferedReader = new BufferedReader(new InputStreamReader(
						inputStream));
				char[] charBuffer = new char[128];
				int bytesRead = -1;
				while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
					stringBuilder.append(charBuffer, 0, bytesRead);
				}
			} else {
				stringBuilder.append("");
			}
		} catch (IOException ex) {
			// to nothing
		} finally {
			if (bufferedReader != null) {
				try {
					bufferedReader.close();
				} catch (IOException ex) {

				}
			}
		}

		if (!StringUtils.isEmpty(stringBuilder)) {
			return stringBuilder.toString();
		}

		if (request.getParameterMap().keySet().size() > 0) {
			return request.getParameterMap().keySet().toArray()[0].toString();
		}

        return null;
	}
600163
@SuppressWarnings("unused")
	public static <T> String getRequestPayload(Request<T> request) {
		Class<?> referenceClazz = request.getClass();
		List<Field> fields = ClassUtil.getAnnotatedFields(referenceClazz, Body.class);
		List<String> objects = new LinkedList<String>();
		for (Field field : fields) {
			Body body = field.getAnnotation(Body.class);

			String asString = ClassUtil.getValueOf(field, request, referenceClazz, String.class);
			return (asString != null ? asString : "");
			// what if there are more bodies?!
		}
		return EMPTY;
	}
1262036
private String getAuthTokenFromRequest(HttpServletRequest httpRequest) {
        String authToken = httpRequest.getHeader(AUTH_TOKEN_HEADER_KEY);

        if (authToken == null) {
            // token can also exist as request parameter
            authToken = httpRequest.getParameter(AUTH_TOKEN_PARAMETER_KEY);
        }

        return authToken;
    }
1333987
public static String getHttpMethod(Span span) {
        if (isHttp(span)) {
            BinaryAnnotation ba = span.getBinaryAnnotation("http.method");
            String httpMethod = null;
            if (ba != null) {
                httpMethod = ba.getValue().toUpperCase();
            } else if (span.getName() != null) {
                httpMethod = span.getName().toUpperCase();
            }

            if (HTTP_METHODS.contains(httpMethod)) {
                return httpMethod;
            }
        }

        return null;
    }
357795
protected boolean isPreFlightRequest(HttpServletRequest request) {
        return (isCorsRequest(request)
                && MethodType.OPTIONS.name().equals(request.getMethod())
                && request.getHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD) != null);
    }
1036905
public static String getQueryParameterValue(RESTRequest request, String name) {
        if (!"post".equalsIgnoreCase(request.getMethod())) {
            return request.getParameter(name);
        }

        if (request.getQueryString() == null) {
            return null;
        }

        Hashtable params = null;
        try {
            params = RequestUtils.parseQueryString(request.getQueryString());
        } catch (Exception e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event("DefaultRoutingHelper", tc, "Failed to parse the query string:\n Exception: " + e);
            }
            return null;
        }

        String[] values = (String[]) params.get(name);
        String value = null;
        if (values != null && values.length > 0)
        {
            value = values[0];
        }

        return value;
    }
466888
public final String getMethod() {
		if(method == null) {
			method = message instanceof Request ? ((Request) message).getMethod()
				: ((CSeqHeader) message.getHeader(CSeqHeader.NAME)).getMethod();
		}
		if(logger.isDebugEnabled()) {
			logger.debug("getMethod - return=" + method);
		}
		return method;
	}
602254
public static Tag method(ContainerRequest request) {
        return (request != null) ? Tag.of("method", request.getMethod()) : METHOD_UNKNOWN;
    }
211307
public SetHttpsConfigResponse setHttpsConfig(SetHttpsConfigRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        InternalRequest internalRequest = 
                createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config");
        internalRequest.addParameter("https", "");
        this.attachRequestToBody(request, internalRequest);
        return invokeHttpClient(internalRequest, SetHttpsConfigResponse.class);
    }
1067989
@Nonnull
  @ReturnsMutableCopy
  public static HttpHeaderMap getResponseHeaderMap (@Nonnull final HttpServletResponse aHttpResponse)
  {
    ValueEnforcer.notNull (aHttpResponse, "HttpResponse");

    final HttpHeaderMap ret = new HttpHeaderMap ();
    for (final String sName : aHttpResponse.getHeaderNames ())
      for (final String sValue : aHttpResponse.getHeaders (sName))
        ret.addHeader (sName, sValue);
    return ret;
  }
368872
public static <T> HttpMethod retrieveMethod(Request<T> request) {
		if (request == null) {
			return null;
		}

		Class<?> clazz = request.getClass();

		Method method = clazz.getAnnotation(Method.class);
		HttpMethod httpMethod = method.value();
		return httpMethod;
	}
590757
public GetPipelineResponse getPipeline(GetPipelineRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        checkStringNotEmpty(request.getPipelineName(), 
                "The parameter pipelineName should NOT be null or empty string.");
        InternalRequest internalRequest =
                createRequest(HttpMethodName.GET, request, PIPELINE, request.getPipelineName());

        return invokeHttpClient(internalRequest, GetPipelineResponse.class);
    }
1019164
public Response makeRequest(final Request request) {

        HttpMethod method = request.getMethod();
        RequestBuilder builder = RequestBuilder.create(method.toString())
            .setUri(request.constructURL().toString())
            .setVersion(HttpVersion.HTTP_1_1)
            .setCharset(StandardCharsets.UTF_8);

        if (request.requiresAuthentication()) {
            builder.addHeader(HttpHeaders.AUTHORIZATION, request.getAuthString());
        }

        if (method == HttpMethod.POST) {
            builder.addHeader(HttpHeaders.CONTENT_TYPE, "application/x-www-form-urlencoded");

            for (Map.Entry<String, List<String>> entry : request.getPostParams().entrySet()) {
                for (String value : entry.getValue()) {
                    builder.addParameter(entry.getKey(), value);
                }
            }
        }

        HttpResponse response = null;

        try {
            response = client.execute(builder.build());
            HttpEntity entity = response.getEntity();
            return new Response(
                // Consume the entire HTTP response before returning the stream
                entity == null ? null : new BufferedHttpEntity(entity).getContent(),
                response.getStatusLine().getStatusCode()
            );
        } catch (IOException e) {
            throw new ApiException(e.getMessage(), e);
        } finally {

            // Ensure this response is properly closed
            HttpClientUtils.closeQuietly(response);

        }

    }
151631
public static HttpServletRequest getOuterRequest( HttpServletRequest request )
    {
        ScopedRequest scopedRequest = unwrapRequest( request );
        return scopedRequest != null ? scopedRequest.getOuterRequest() : request;
    }