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


Java HttpMethod.valueOf方法代码示例

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


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

示例1: extractMethod

import org.apache.olingo.commons.api.http.HttpMethod; //导入方法依赖的package包/类
/**
 * Extract method.
 *
 * @param odRequest
 *            the od request
 * @param httpRequest
 *            the http request
 * @throws ODataTranslatedException
 *             the o data translated exception
 */
private void extractMethod(final ODataRequest odRequest,
		final HttpServletRequest httpRequest)
		throws ODataTranslatedException {
	try {
		HttpMethod httpRequestMethod = HttpMethod.valueOf(httpRequest
				.getMethod());

		if (httpRequestMethod == HttpMethod.POST) {
			String xHttpMethod = httpRequest
					.getHeader(HttpHeader.X_HTTP_METHOD);
			String xHttpMethodOverride = httpRequest
					.getHeader(HttpHeader.X_HTTP_METHOD_OVERRIDE);

			if (xHttpMethod == null && xHttpMethodOverride == null) {
				odRequest.setMethod(httpRequestMethod);
			} else if (xHttpMethod == null) {
				odRequest
						.setMethod(HttpMethod.valueOf(xHttpMethodOverride));
			} else if (xHttpMethodOverride == null) {
				odRequest.setMethod(HttpMethod.valueOf(xHttpMethod));
			} else {
				if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
					throw new ODataHandlerException(
							"Ambiguous X-HTTP-Methods",
							ODataHandlerException.MessageKeys.AMBIGUOUS_XHTTP_METHOD,
							xHttpMethod, xHttpMethodOverride);
				}
				odRequest.setMethod(HttpMethod.valueOf(xHttpMethod));
			}
		} else {
			odRequest.setMethod(httpRequestMethod);
		}
	} catch (IllegalArgumentException e) {
		throw new ODataHandlerException("Invalid HTTP method"
				+ httpRequest.getMethod(),
				ODataHandlerException.MessageKeys.INVALID_HTTP_METHOD,
				httpRequest.getMethod());
	}
}
 
开发者ID:rohitghatol,项目名称:spring-boot-Olingo-oData,代码行数:50,代码来源:EDMController.java

示例2: parseMethod

import org.apache.olingo.commons.api.http.HttpMethod; //导入方法依赖的package包/类
private HttpMethod parseMethod(final String method) throws BatchDeserializerException {
  try {
    return HttpMethod.valueOf(method.trim());
  } catch (IllegalArgumentException e) {
    throw new BatchDeserializerException("Illegal http method", e, MessageKeys.INVALID_METHOD,
        Integer.toString(statusLine.getLineNumber()));
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:9,代码来源:HttpRequestStatusLine.java


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