本文整理汇总了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());
}
}
示例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()));
}
}