Get the "real" HTTP method for the request, taking into account the X-HTTP-Method-Override
header.

@param req a {@code ServletRequest}
@return the HTTP method for the request
502346
public static String getRealHttpMethod(ServletRequest req) {
    HttpServletRequest httpRequest = (HttpServletRequest) req;
    String method = (String) httpRequest.getAttribute(HTTP_METHOD_OVERRIDE_ATTRIBUTE);
    if (method != null) {
      return method;
    }
    return httpRequest.getMethod();
  }
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;
	}
292664
public ServletRequest getServletRequest()
    {
        RequestContext reqContext = peekRequestContext();
        if (reqContext == null)
            return null;

        return  reqContext._request;
    }
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);

        }

    }
220004
public WebReply getHTTPSRedirectWebReply(HttpServletRequest req) {

        Integer httpsPort = (Integer) SRTServletRequestUtils.getPrivateAttribute(req, "SecurityRedirectPort");
        if (httpsPort == null) {
            Tr.error(tc, "SSL_PORT_IS_NULL");
            // return a 403 if we don't know what the port is
            return new DenyReply("Resource must be accessed with a secure connection try again using an HTTPS connection.");
        }

        URL originalURL = null;
        String urlString = null;
        try {
            urlString = req.getRequestURL().toString();
            originalURL = new URL(urlString);
        } catch (MalformedURLException e) {
            Tr.error(tc, "SSL_REQ_URL_MALFORMED_EXCEPTION", urlString);
            // return a 403 if we can't construct the redirect URL
            return new DenyReply("Resource must be accessed with a secure connection try again using an HTTPS connection.");
        }
        String queryString = req.getQueryString();
        try {
            URL redirectURL = new URL("https",
                            originalURL.getHost(),
                            httpsPort,
                            originalURL.getPath() + (queryString == null ? "" : "?" + queryString));

            //don't add cookies during the redirect as this results in duplicated and incomplete
            //cookies on the client side
            return new RedirectReply(redirectURL.toString(), null);
        } catch (MalformedURLException e) {
            Tr.error(tc, "SSL_REQ_URL_MALFORMED_EXCEPTION", "https" + originalURL.getHost() + httpsPort + originalURL.getPath() + (queryString == null ? "" : "?" + queryString));
            // return a 403 if we can't construct the redirect URL
            return new DenyReply("Resource must be accessed with a secure connection try again using an HTTPS connection.");
        }
    }
1063779
public static String getLocation (HttpServletRequest req)
    {
        StringBuffer rurl = req.getRequestURL();
        String qs = req.getQueryString();
        if (qs != null) {
            rurl.append("?").append(qs);
        }
        return rurl.toString();
    }
1255047
public RpcResponse request(RpcRequest req) {
        InputStream is = null;
        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            serializer.write(req.marshal(contract), bos);
            bos.close();
            byte[] data = bos.toByteArray();

            is = requestRaw(data);
            return unmarshal(req, serializer.readMap(is));
        }
        catch (RpcException e) {
            return new RpcResponse(req, e);
        }
        catch (IOException e) {
            String msg = "IOException requesting " + req.getMethod() + 
                " from: " + endpoint + " - " + e.getMessage();
            RpcException exc = RpcException.Error.INTERNAL.exc(msg);
            return new RpcResponse(req, exc);
        }
        finally {
            closeQuietly(is);
        }
    }
435972
@Nullable
  public static EHttpMethod getHttpMethod (@Nonnull final HttpServletRequest aHttpRequest)
  {
    ValueEnforcer.notNull (aHttpRequest, "HttpRequest");

    final String sMethod = aHttpRequest.getMethod ();
    return EHttpMethod.getFromNameOrNull (sMethod);
  }
266756
@Nonnull
  protected MockHttpServletResponse getMockHttpServletResponse (@Nonnull final ServletResponse aResponse)
  {
    if (aResponse instanceof MockHttpServletResponse)
      return (MockHttpServletResponse) aResponse;
    if (aResponse instanceof HttpServletResponseWrapper)
      return getMockHttpServletResponse (((HttpServletResponseWrapper) aResponse).getResponse ());

    throw new IllegalArgumentException ("MockRequestDispatcher requires MockHttpServletResponse");
  }
433933
public static HttpServletRequest getHttpServletRequest(final Request request)
	{
		final WebRequest webRequest = (WebRequest)request;
		final HttpServletRequest httpServletRequest = (HttpServletRequest)webRequest
			.getContainerRequest();
		return httpServletRequest;
	}
402595
protected function getRequestMethod()
    {
        if (isset($this->server['REQUEST_METHOD'])) {
            // check for X-HTTP-Method-Override
            if (isset($this->server['HTTP_X_HTTP_METHOD_OVERRIDE']) && in_array($this->server['HTTP_X_HTTP_METHOD_OVERRIDE'], ['OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'PATCH'])) {
                return $this->server['HTTP_X_HTTP_METHOD_OVERRIDE'];
            } else {
                return $this->server['REQUEST_METHOD'];
            }
        } else {
            return 'GET';
        }
    }
572714
protected function detectMethod(HttpRequest $request)
	{
		$requestMethod = $request->getMethod();
		if ($requestMethod !== 'POST') {
			return $request->getMethod();
		}

		$method = $request->getHeader(self::HTTP_HEADER_OVERRIDE);
		if (isset($method)) {
			return strtoupper($method);
		}

		$method = $request->getQuery(self::QUERY_PARAM_OVERRIDE);
		if (isset($method)) {
			return strtoupper($method);
		}

		return $requestMethod;
	}
735201
public java.lang.String getHttpHeader() {
    java.lang.Object ref = httpHeader_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      httpHeader_ = s;
      return s;
    }
  }
197983
public static HttpServletRequest getHttpServletRequestFromExternalWebflowContext() {
        val servletExternalContext = (ServletExternalContext) ExternalContextHolder.getExternalContext();
        if (servletExternalContext != null) {
            return (HttpServletRequest) servletExternalContext.getNativeRequest();
        }
        return null;

    }
272840
@Sensitive
    public static String getHeader(HttpServletRequest req, String key) {
        HttpServletRequest sr = getWrappedServletRequestObject(req);
        return sr.getHeader(key);
    }
1329923
public String getRequestInfo(HttpServletRequest request) {
        return String.format("URI: %s; Scheme: %s; Host: %s; Port: %s; Origin: %s; Method: %s",
                             request.getRequestURI(),
                             request.getScheme(),
                             request.getServerName(),
                             request.getServerPort(),
                             request.getHeader("Origin"),
                             request.getMethod());
    }
575905
public static String reconstructURL (HttpServletRequest req)
    {
        StringBuffer buf = req.getRequestURL();
        @SuppressWarnings("unchecked") Map<String, String[]> map = req.getParameterMap();
        if (map.size() > 0) {
            buf.append("?");
            for (Map.Entry<String, String[]> entry : map.entrySet()) {
                if (buf.charAt(buf.length()-1) != '?') {
                    buf.append("&");
                }
                buf.append(entry.getKey()).append("=");
                String[] values = entry.getValue();
                if (values.length == 1) {
                    buf.append(values[0]);
                } else {
                    buf.append("(");
                    for (int ii = 0; ii < values.length; ii++) {
                        if (ii > 0) {
                            buf.append(", ");
                        }
                        buf.append(values[ii]);
                    }
                    buf.append(")");
                }
            }
        }
        return buf.toString();
    }