Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Limit of bytes that can be sent to server?

 
Michael Hubele
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have some j2me code that I got from a tutorial that sends a picture that is captured from the screen of the phone and is sent to my asp.net webpage.

The picture length is like 78,000 bytes and then I encode it base64 and I am not sure how long it is after this.

I then use the outputStream to send it.

When it hits my asp.net webpage I use

Stream stream = Request.InputStream;

I get a length of 0.

I played around and found that the max bytes that seem to work is 1512 and when it his my C# line above it has a length of 2016. Is this how it should be?

Like the tutorial I was going through used java servlets to do it and this is what they did

InputStream in = request.getInputStream();

So it is almost the same as my c# code.

but they don't say anything about any limits or anything on how much can be sent.

 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTTP requests are blocking streams. There is nothing at the server side until you read it. So just read the stream up to the last bit.

If you want to know the content length beforehand, you can usually find it in the request header. But you shouldn't rely on it only, because the value can be spoofed or 'forgotten' by the software used at the client side.
 
Michael Hubele
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:HTTP requests are blocking streams. There is nothing at the server side until you read it. So just read the stream up to the last bit.

If you want to know the content length beforehand, you can usually find it in the request header. But you shouldn't rely on it only, because the value can be spoofed or 'forgotten' by the software used at the client side.


Sorry I am not following.

I tried to read the stream if I am understanding you correctly.

Stream stream = Request.InputStream;
StreamReader streamReader = new StreamReader(stream);

string test = streamReader.ReadToEnd();
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try a forum devoted to C#.

At least I can tell you that HTTP requests are blocking IO. In Java you should basically read every byte of the inputstream in a loop until its value is -1.
 
Michael Hubele
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bauke Scholtz wrote:Try a forum devoted to C#.

At least I can tell you that HTTP requests are blocking IO. In Java you should basically read every byte of the inputstream in a loop until its value is -1.


hmm I will try a C# form but they probably go and tell me to go to a j2me forum.
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1512 bytes sounds like a limit for an HTTP GET. I think you're trying to do this the hard way.

Set up your C# server to do file uploads. Then write the J2ME code as a file upload client using HTTP POST. POST, unlike GET is designed for very large amounts of data to be sent to the server.
 
Michael Hubele
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:1512 bytes sounds like a limit for an HTTP GET. I think you're trying to do this the hard way.

Set up your C# server to do file uploads. Then write the J2ME code as a file upload client using HTTP POST. POST, unlike GET is designed for very large amounts of data to be sent to the server.


Hmm I am not sure what you mean make C# server to do file uploads. IN my j2me code I am using a Post I did the setting as a post.

c.setRequestMethod(HttpConnection.POST);

I thought there might be a limit on what .net allows but changed the limit from 4mb(what should have been tons) to 100mbs. I also tried sending the string that makes up the jpg through a diff .net website and it works no problem.

So i don't know what is up. The .net that send the jpg used a dataStream since I could not find really how to use the .net outputStream where the j2me midlet uses the output stream but the code that grabs the image from either one is the exactly the same.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic