Permalink
Browse files

Chunked requests don't have a predefined content length, but definite…

…ly have content!
  • Loading branch information...
1 parent 00db4c3 commit 291a755b4d7193c0334b8359d50d8a3b40a24a21 @Infiniverse Infiniverse committed Feb 6, 2014
@@ -133,10 +133,8 @@ protected Sequence extractRequestBody(final HttpRequest request) throws RestXqSe
//first, get the content of the request
is = new CloseShieldInputStream(request.getInputStream());
-
- //if the content length is unknown or 0, return
- final int contentLength = request.getContentLength();
- if(contentLength == -1 || contentLength == 0) {
+
+ if(is.available() <= 0) {
return null;
}
@@ -162,18 +160,7 @@ public String getCacheClass() {
try {
//was there any POST content?
-
-
- /**
- * There is a bug in HttpInput.available() in Jetty 7.2.2.v20101205
- * This has been filed as Bug 333415 - https://bugs.eclipse.org/bugs/show_bug.cgi?id=333415
- * It is expected to be fixed in the Jetty 7.3.0 release
- */
-
- //TODO reinstate call to .available() when Jetty 7.3.0 is released, use of .getContentLength() is not reliable because of http mechanics
- //if(is != null && is.available() > 0) {
- final int contentLength = request.getContentLength();
- if(is != null && contentLength > 0) {
+ if(is != null && is.available() > 0) {
String contentType = request.getContentType();
// 1) determine if exists mime database considers this binary data
if(contentType != null) {
@@ -227,6 +214,8 @@ public String getCacheClass() {
}
}
}
+ } catch (IOException e) {
+ throw new RestXqServiceException(e.getMessage());
} finally {
if(cache != null) {

0 comments on commit 291a755

Please sign in to comment.