Re: [rest-assured] Content-Length incorrect when using streams?

684 views
Skip to first unread message

Johan Haleby

unread,
Jun 25, 2015, 7:09:40 AM6/25/15
to rest-a...@googlegroups.com
In what way does the test fail? Do you expect 413 or is the problem that 413 is not returned by the server? Or is it the content-length that is the problem? Perhaps you could try setting a content-length manually as a header and see if that helps?

Regards,
/Johan

On Wed, Jun 24, 2015 at 8:03 PM, Steve Warshawsky <siwars...@gmail.com> wrote:
Hello again.  We're using rest-assured to test our object storage cloud solution and most of our tests are successful but when we attempt to upload an object with a length that's greater than the maximum permitted by the system the test fails.  Here's the code we've been using:

    given().spec(adminAStroageAccessBasicAuth)).
        contentType(ContentType.BINARY).
        content(new BufferedInputStream(new FileInputStream(file))).
    when().
        put("/" + containerName + "/" + testFile6G).
    then().
        statusCode(413);

What's interesting is that the file completes upload, then the backend responds with a '413' error.  I think I have a theory for this behaviour, it's because an incorrect value for Content-Length is being sent in the 'PUT', the value I captured with Wireshark is '0'.

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steve Warshawsky

unread,
Jun 25, 2015, 8:09:42 AM6/25/15
to rest-a...@googlegroups.com
When a similar command is executed with Curl the backend immediately responds with a '413'.  With rest-assured the '413' is returned only after the file completes upload which can take a while when the file is 6Gb.  When the 'Content-Length' header is added to the RA code the call fails because "Content-Length header already present."

Sent from my iPad

Steve Warshawsky

unread,
Jun 25, 2015, 5:05:21 PM6/25/15
to rest-a...@googlegroups.com
We suspect this behaviour's due to chunking and there's no easy workaround with rest-assured or HttpClient.  Thanks again.

Johan Haleby

unread,
Jun 26, 2015, 1:55:46 PM6/26/15
to rest-a...@googlegroups.com
Thanks for sharing. But if your server looks at the content-type header, wouldn't it be possible to simple set a content-type header and not send any data?

/Johan
Reply all
Reply to author
Forward
0 new messages