4

Background

I have a simple html form:

<form action="/upload" method="POST" enctype="multipart/form-data">
    <input type="hidden" id="p" name="p" />
    <input type="hidden" id="n" name="n" />
    <input type="file" class="upload-file" id="file" name="file" />
    <textarea id="o" name="o"></textarea>
    <button type="submit" >Send</button>
</form>
<script>
    $(function(){
        var fileInput = $('.upload-file');
        $('.upload-form').submit(function(e){
            $("#n").val($('input[type=file]').val());
            if(!fileInput.get(0).files.length){
                alert('Select a file');
                return false;
            }
        });
    });
</script>

And a simple Rest easy consumer:

@POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response upload(@MultipartForm FormDTO form) {
    form.getData(); //<-- breakpoint here
}

Problem

Trying to upload files below 16KB throws (Doesn't hit the breakpoint):

WARN  [org.apache.james.mime4j.parser.MimeEntity] Unexpected end of headers detected. Higher level boundary detected or EOF reached.
WARN  [org.apache.james.mime4j.parser.MimeEntity] Invalid header encountered
WARN  [org.apache.james.mime4j.parser.MimeEntity] Body part ended prematurely. Boundary detected in header or EOF reached.
ERROR Could find no Content-Disposition header within part.

Files larger than 16 KB are fine and working (Hits the BreakPoint). (Tried increasing character by character until get bigger than 16KB).

Consideration

Is there a minimum post size threshold for Apache, Wildfly, Resteasy or JaxRS?

Thank you

ATTACHMENTS:

Firebug POST file larger than 16KB (Fine!)

-----------------------------3380429991862985457771888012
Content-Disposition: form-data; name="p"

TOKEN
-----------------------------3380429991862985457771888012
Content-Disposition: form-data; name="n"


-----------------------------3380429991862985457771888012
Content-Disposition: form-data; name="file"; filename="filename"
Content-Type: application/octet-stream

LARGE lorem ipsum TEXT OMMITED

-----------------------------3380429991862985457771888012
Content-Disposition: form-data; name="o"


-----------------------------3380429991862985457771888012--

Firebug POST file smaller than 16KB (Not fine!)

-----------------------------10552095891001881326598189114
Content-Disposition: form-data; name="p"

TOKEN
-----------------------------10552095891001881326598189114
Content-Disposition: form-data; name="n"


-----------------------------10552095891001881326598189114
Content-Disposition: form-data; name="file"; filename="fileSmaller"
Content-Type: application/octet-stream

SMALLER lorem ipsum text OMMITED

-----------------------------10552095891001881326598189114
Content-Disposition: form-data; name="o"


-----------------------------10552095891001881326598189114--

Testing Very Bad and Ugly workaround if File is <16KB:

Fills (javascript loop) with 16KB characters (zeros) an input hidden 'x' and submit WORKS and small files can be sent. (Of course it is not recommended)

Redhat issue https://access.redhat.com/solutions/4521051

Solano
  • 550
  • 2
  • 9
  • 1
    I've upvoted your question, but I'm skeptical that the issue has been debugged correctly. I wonder if your less than 16kb file is actually corrupt. What type of file is it? What are the contents? – DavidS Nov 01 '16 at 16:39
  • 1
    Plain Lorem Ipsum text... Updating the post with jquery related script that also exists... – Solano Nov 01 '16 at 16:40
  • 1
    Is there a stacktrace, or just those three log messages? – DavidS Nov 01 '16 at 16:45
  • 1
    Also, if you use Chrome Dev Tools to review the content of the POST, maybe you can find something different between the two files? Are the headers different? – DavidS Nov 01 '16 at 16:47
  • 1
    Stacktrace: http://pastebin.com/nh0FakMk – Solano Nov 01 '16 at 16:49
  • 1
    Firebug post (Network Tab) added as attachment – Solano Nov 01 '16 at 16:57

0 Answers0