Hi Edinson,

Indeed, it was not a Groovy problem !

Thanks for your answer.

Philippe


Le 27/04/2016 à 14:03, Edinson E. Padrón Urdaneta a écrit :
Hi there,

It should be notice that `HttpURLConnection` comes from Java and not from Groovy.

After a quick Google search I got:

"HttpURLConnection does support the POST method, try setRequestMethod("POST"). Also persistent connections are supported. Note that the connection is only re-used after you have read the response body. In the code example you posted it doesn't look like you are reading the response. Since jdk6 the HTTP protocol handler will attempt to read-ahead to make the connection available for re-use. It reads to up ~512k so if the HTTP server returns megabytes of data and you aren't reading it then the connection will be closed and not re-used." [1]

"|HttpURLConnection| <http://download.oracle.com/javase/6/docs/api/java/net/HttpURLConnection.html> *will* reuse connections if it can <http://download.oracle.com/javase/6/docs/technotes/guides/net/http-keepalive.html>!

For this to work, several preconditions need to be fulfilled, mostly on the server side. Those preconditions are described in the article linked to above." [2]

[1] https://community.oracle.com/thread/1147187?start=0&tstart=0
[2] http://stackoverflow.com/a/5459200

Hope it helps. And remember, Google is your friend.


On Wed, Apr 27, 2016 at 6:46 AM, Philippe Chantry <[email protected] <mailto:[email protected]>> wrote:

    Hi all,

    I'm trying to upload files to an ECM with a multipart POST HTTP
    request using HttpURLConnection.

    It works fine if the file size is less than or equal to 524288
    bytes (= 512k), and fails if the file is larger.

    Is 512k an inner limitation of groovy for a POST parameter size ?
    Is there some workarounds ?

    (The same program written in pure java has not this limitation
    problem.)

    Thank you,
    Philippe



--
*Philippe Chantry*
Ingénieur de développement
logo INP
        
Tél : +33 (0)5 34 32 30 83
INSTITUT NATIONAL POLYTECHNIQUE DE TOULOUSE
6 allée Emile Monso - BP 34038 - 31029 Toulouse cedex 4

Reply via email to