diff --git a/lib/server-api/pom.xml b/lib/server-api/pom.xml
index 6d3987ee4..f6511164c 100644
--- a/lib/server-api/pom.xml
+++ b/lib/server-api/pom.xml
@@ -50,6 +50,11 @@
junit
junit
+
+ io.netty
+ netty-all
+ 4.1.16.Final
+
diff --git a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java
index 4c18e2e25..61e0f0f93 100644
--- a/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java
+++ b/lib/server-api/src/main/java/org/apache/olingo/server/api/ODataHttpHandler.java
@@ -39,7 +39,7 @@ public interface ODataHttpHandler extends ODataHandler {
* @param response - HTTP OData response
*/
void process(HttpServletRequest request, HttpServletResponse response);
-
+
/**
* Sets the split parameter which is used for service resolution.
* @param split the number of path segments reserved for service resolution; default is 0
diff --git a/lib/server-core/pom.xml b/lib/server-core/pom.xml
index 7f88e0815..2e7ed61f9 100644
--- a/lib/server-core/pom.xml
+++ b/lib/server-core/pom.xml
@@ -79,6 +79,11 @@
org.mockito
mockito-all
+
+ io.netty
+ netty-all
+ 4.1.16.Final
+
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
index 6c4b1b3f6..bbd94e509 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/ODataHttpHandlerImpl.java
@@ -125,7 +125,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
environment.put("servletPath", request.getServletPath());
return environment;
}
-
+
private String getIntAsString(final int number) {
return number == 0 ? "unknown" : Integer.toString(number);
}
@@ -164,7 +164,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
writeContent(odResponse, response);
}
}
-
+
static void writeContent(final ODataResponse odataResponse, final HttpServletResponse servletResponse) {
try {
ODataContent res = odataResponse.getODataContent();
@@ -195,7 +195,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
closeStream(output);
}
}
-
+
private static void closeStream(final Channel closeable) {
if (closeable != null) {
try {
@@ -205,7 +205,7 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
}
}
}
-
+
private ODataRequest fillODataRequest(final ODataRequest odRequest, final HttpServletRequest httpRequest,
final int split) throws ODataLibraryException {
final int requestHandle = debugger.startRuntimeMeasurement("ODataHttpHandlerImpl", "fillODataRequest");
@@ -228,43 +228,44 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
debugger.stopRuntimeMeasurement(requestHandle);
}
}
-
+
static HttpMethod extractMethod(final HttpServletRequest httpRequest) throws ODataLibraryException {
- final HttpMethod httpRequestMethod;
- try {
- httpRequestMethod = HttpMethod.valueOf(httpRequest.getMethod());
- } catch (IllegalArgumentException e) {
- throw new ODataHandlerException("HTTP method not allowed" + httpRequest.getMethod(), e,
- ODataHandlerException.MessageKeys.HTTP_METHOD_NOT_ALLOWED, httpRequest.getMethod());
- }
- try {
- if (httpRequestMethod == HttpMethod.POST) {
- String xHttpMethod = httpRequest.getHeader(HttpHeader.X_HTTP_METHOD);
- String xHttpMethodOverride = httpRequest.getHeader(HttpHeader.X_HTTP_METHOD_OVERRIDE);
+ final HttpMethod httpRequestMethod;
+ try {
+ httpRequestMethod = HttpMethod.valueOf(httpRequest.getMethod());
+ } catch (IllegalArgumentException e) {
+ throw new ODataHandlerException("HTTP method not allowed" + httpRequest.getMethod(), e,
+ ODataHandlerException.MessageKeys.HTTP_METHOD_NOT_ALLOWED, httpRequest.getMethod());
+ }
+ try {
+ 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) {
- return httpRequestMethod;
- } else if (xHttpMethod == null) {
- return HttpMethod.valueOf(xHttpMethodOverride);
- } else if (xHttpMethodOverride == null) {
- return HttpMethod.valueOf(xHttpMethod);
- } else {
- if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
- throw new ODataHandlerException("Ambiguous X-HTTP-Methods",
- ODataHandlerException.MessageKeys.AMBIGUOUS_XHTTP_METHOD, xHttpMethod, xHttpMethodOverride);
- }
- return HttpMethod.valueOf(xHttpMethod);
- }
- } else {
- return httpRequestMethod;
- }
- } catch (IllegalArgumentException e) {
- throw new ODataHandlerException("Invalid HTTP method" + httpRequest.getMethod(), e,
- ODataHandlerException.MessageKeys.INVALID_HTTP_METHOD, httpRequest.getMethod());
- }
- }
-
- static void fillUriInformation(final ODataRequest odRequest, final HttpServletRequest httpRequest, final int split) {
+ if (xHttpMethod == null && xHttpMethodOverride == null) {
+ return httpRequestMethod;
+ } else if (xHttpMethod == null) {
+ return HttpMethod.valueOf(xHttpMethodOverride);
+ } else if (xHttpMethodOverride == null) {
+ return HttpMethod.valueOf(xHttpMethod);
+ } else {
+ if (!xHttpMethod.equalsIgnoreCase(xHttpMethodOverride)) {
+ throw new ODataHandlerException("Ambiguous X-HTTP-Methods",
+ ODataHandlerException.MessageKeys.AMBIGUOUS_XHTTP_METHOD, xHttpMethod, xHttpMethodOverride);
+ }
+ return HttpMethod.valueOf(xHttpMethod);
+ }
+ } else {
+ return httpRequestMethod;
+ }
+ } catch (IllegalArgumentException e) {
+ throw new ODataHandlerException("Invalid HTTP method" + httpRequest.getMethod(), e,
+ ODataHandlerException.MessageKeys.INVALID_HTTP_METHOD, httpRequest.getMethod());
+ }
+ }
+
+ static void fillUriInformation(final ODataRequest odRequest,
+ final HttpServletRequest httpRequest, final int split) {
String rawRequestUri = httpRequest.getRequestURL().toString();
String rawODataPath;
@@ -274,10 +275,12 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
int beginIndex = rawRequestUri.indexOf(requestMapping) + requestMapping.length();
rawODataPath = rawRequestUri.substring(beginIndex);
}else if(!"".equals(httpRequest.getServletPath())) {
- int beginIndex = rawRequestUri.indexOf(httpRequest.getServletPath()) + httpRequest.getServletPath().length();
+ int beginIndex = rawRequestUri.indexOf(httpRequest.getServletPath()) +
+ httpRequest.getServletPath().length();
rawODataPath = rawRequestUri.substring(beginIndex);
} else if (!"".equals(httpRequest.getContextPath())) {
- int beginIndex = rawRequestUri.indexOf(httpRequest.getContextPath()) + httpRequest.getContextPath().length();
+ int beginIndex = rawRequestUri.indexOf(httpRequest.getContextPath()) +
+ httpRequest.getContextPath().length();
rawODataPath = rawRequestUri.substring(beginIndex);
} else {
rawODataPath = httpRequest.getRequestURI();
@@ -310,13 +313,13 @@ public class ODataHttpHandlerImpl implements ODataHttpHandler {
}
static void copyHeaders(ODataRequest odRequest, final HttpServletRequest req) {
- for (final Enumeration> headerNames = req.getHeaderNames(); headerNames.hasMoreElements();) {
- final String headerName = (String) headerNames.nextElement();
- @SuppressWarnings("unchecked")
- // getHeaders() says it returns an Enumeration of String.
- final List headerValues = Collections.list(req.getHeaders(headerName));
- odRequest.addHeader(headerName, headerValues);
- }
+ for (final Enumeration> headerNames = req.getHeaderNames(); headerNames.hasMoreElements();) {
+ final String headerName = (String) headerNames.nextElement();
+ @SuppressWarnings("unchecked")
+ // getHeaders() says it returns an Enumeration of String.
+ final List headerValues = Collections.list(req.getHeaders(headerName));
+ odRequest.addHeader(headerName, headerValues);
+ }
}
@Override
diff --git a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ServerCoreDebugger.java b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ServerCoreDebugger.java
index cf80073fd..1fd85b788 100644
--- a/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ServerCoreDebugger.java
+++ b/lib/server-core/src/main/java/org/apache/olingo/server/core/debug/ServerCoreDebugger.java
@@ -62,7 +62,7 @@ public class ServerCoreDebugger {
}
}
}
-
+
public ODataResponse createDebugResponse(final ODataRequest request, final ODataResponse response,
final Exception exception, final UriInfo uriInfo, final Map serverEnvironmentVariables) {
// Failsafe so we do not generate unauthorized debug messages