Does Content-Length can't exceed 2,147,483,648?

C

crazytazo

Does Content-Length can't exceed 2,147,483,648?

This is my applet's codes.

HttpURLConnection connection = null;
connection = (HttpURLConnection) netUrl.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "multipart/form-data;
boundary=" + sBoundary);
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setAllowUserInteraction(false);
connection.setFixedLengthStreamingMode((int) jContentLength); //
<--- !!!

setFixedLengthStreamingMode method accept Integer only.
But I wish send large file more than Integer.

How to solve it?
-----------------------------------------------------------------
I'm sorry that i cannot give you a full detail of questions because of
my poor english.
I'm so appreciate your good answers in news group.

http://crazytazo.com
 
O

Owen Jacobson

Does Content-Length can't exceed 2,147,483,648?

This is my applet's codes.

HttpURLConnection connection = null;
connection = (HttpURLConnection) netUrl.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "multipart/form-data;
boundary=" + sBoundary);
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setAllowUserInteraction(false);
connection.setFixedLengthStreamingMode((int) jContentLength); //
<--- !!!

setFixedLengthStreamingMode method accept Integer only.
But I wish send large file more than Integer.

How to solve it?

Short answer: by not using the HttpURLConnection class, I suppose,
since HttpURLConnection only allows ints for content length. However,
there are two deeper, weirder issues here.

1 - Are you sure HTTP is the best protocol for uploading 2GB-and-
larger blocks of data? Something that supports resuming(*) might be a
better idea, when your data's that large. Even over GigE that's going
to take around 30 seconds on a totally uncongested network; over
100Mbit networks, or, worse, the internet, 2GB is going to take much
longer.

2 - While RFC 2616 doesn't constrain Content-Length:, I wouldn't be
surprised if some fairly common HTTP implementations assume it fits in
an int. You may run into problems on the server by posting a body
larger than 2**31 bytes. Obviously, the only way to find out is to try
it, or to read the source for the server.

-o

(*) Yes, HTTP supports resuming - on *downloads*, via making a second
GET request for the missing bits. This doesn't work so well for
request data in POSTs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top