Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2008 > C# 2008 aka C# 3.0
C# 2008 aka C# 3.0 Discuss the Visual C# 2008 (aka C# 3.0) language
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2008 aka C# 3.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 15th, 2009, 11:00 PM
Friend of Wrox
Join Date: Sep 2007
Posts: 169
Thanks: 7
Thanked 2 Times in 2 Posts
Default Question about Request.InputStream


I am not sure what I am doing wrong I got j2me mobile app I am making and I am trying to send a picture to the server.

the pictures length is like 78,000 bytes. and then I encode it in base 64 before I sent it with j2me outputstream.

my code gets hit but the

Request.InputStream length equals 0 though. I don't understand why though.

I been playing around and found that the max I seem to be able to send is 1512 bytes in length what works out to be 2016 bytes in length in the base 64 encoding(this is the lenght of the Request.InputStream).

I am not sure why if it goes any higher then this it does not work.

I tired asking around in the j2me forums cuz I thought there might not be a contraint on how much you can send but that does not seem to be the case.

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.
This is my code and as far as I understand I am trying to get the length.

protected void Page_Load(object sender, EventArgs e)
            if (Request.Headers["user-agent"] == "MIDlet")

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

                    string test = streamReader.ReadToEnd();

                    byte[] raw = Convert.FromBase64String(test);

                    string desktop = Environment.CurrentDirectory + "\test.jpg";

                    File.WriteAllBytes(desktop, raw);

                catch (Exception ex)



Similar Threads
Thread Thread Starter Forum Replies Last Post
Buffers, InputStream & ByteArrayOutputStream erobb BOOK: Beginning Java 2 0 March 21st, 2008 01:01 AM
Request question thunder Classic ASP Basics 1 February 26th, 2006 10:29 AM
Using font created by createFont(int, InputStream) smshinde Java GUI 0 March 13th, 2005 01:58 PM
Request.ServerVariables HTTP_REFERRER question savoym Classic ASP Basics 6 May 25th, 2004 02:05 PM
InputStream and OutputStream in javascript?? bikash Javascript 3 July 25th, 2003 05:05 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.