×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    13

    Exclamation HttpConnection.POST return error code 500

    I want to upload an image to a web page which written in ASP3.0. But when I call conn.getResponseCode(), it return 500 server error.
    I check the asp page, when run to line Request.BinaryRead (RequestSize), failed.
    Seems the data post by MIDP connection can't be read by asp request object.
    Any solution to this? I need help, Thanks.

    Code:
    Midlet:
    conn = (HttpConnection) Connector.open("http://192.168.0.1/test.asp");
    conn.setRequestMethod(HttpConnection.POST);
    setRequestHeaders(conn);
    os = conn.openOutputStream();
    os.write("Somedata".getBytes());
    os.flush();
    // Get the status code, causing the connection to be made
    status = conn.getResponseCode();

    ASPtest.asp)
    RequestSize = Int(Request.TotalBytes)
    RequestBinData = Request.BinaryRead (RequestSize)

    If I call this asp page in IE, It's ok.
    And I write a Symbian C++ client use RSocket to post http data, It also works.(Request.BinaryRead can get the data.)
    I don't know if there any differece in MIDP2.0.

    If I do not write those lines:
    os = conn.openOutputStream();
    os.write("Somedata".getBytes());
    os.flush();
    response code will be 200.
    Request.BinaryRead return null, but without error.

    ...^_^...

  2. #2
    Super Contributor
    Join Date
    Mar 2006
    Location
    Phoenix, AZ. USA
    Posts
    556

    Re: HttpConnection.POST return error code 500

    do you need to set the content length header?
    Jason Glass
    http://IChiBanComputers.Com

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    13

    Re: HttpConnection.POST return error code 500

    Yes, I've set the content length header. Exactly, I set all the headers I set in my Symbian C++ client which works.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Posts
    13

    Re: HttpConnection.POST return error code 500

    I found the problem,
    HttpConnection will set the http header with 'Transfer-Encoding: chunked'.
    And the header 'Content-Length' I set was discarded. Then the ASP server can't get the content length, and readbinary will fail.

    Any one knows how to set the Content-Length header in HttpConnect?
    Thanks.

  5. #5
    Super Contributor
    Join Date
    Mar 2006
    Location
    Phoenix, AZ. USA
    Posts
    556

    Re: HttpConnection.POST return error code 500

    can you just set the content encoding yourself, cus j2me defaults to chunked, i think, then it might not toss out your content length.

    or, you might want to keep it all, as chunking, helps with uploading in multi part so it gets through the carriers, and devices limits

    IIS servers, I think, default to chunked mode, if content length is not set
    Jason Glass
    http://IChiBanComputers.Com

  6. #6
    Registered User
    Join Date
    Sep 2004
    Posts
    13

    Re: HttpConnection.POST return error code 500

    If I post the data less than 2016, everything will be ok. The content-length then can be set, and not chunked.
    If write more than 2016 bytes to outputstream , the data will be chunked, and conent-length will be erased even you set it to the HttpConnection.
    I think it's the HttpConnection's implement. We can't change this behaviour.

  7. #7
    Super Contributor
    Join Date
    Mar 2006
    Location
    Phoenix, AZ. USA
    Posts
    556

    Re: HttpConnection.POST return error code 500

    yeah, probably is implementation specific, be nice if you could find out the limit in advance, and if necessary, resort to chunked.

    so are you just gonna implement chunked uploads on server?
    Jason Glass
    http://IChiBanComputers.Com

Similar Threads

  1. stupid error!
    By bojkar in forum Symbian
    Replies: 1
    Last Post: 2006-12-14, 05:47
  2. Replies: 6
    Last Post: 2005-10-03, 05:51
  3. 关于Float的问题,急死了,各位帮忙一下,谢谢!
    By show_up in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 4
    Last Post: 2004-08-17, 08:57
  4. Return code 50397198???
    By koenjo in forum Multimodecards
    Replies: 2
    Last Post: 2003-06-17, 14:27
  5. How to make singleton
    By rownak_hasan in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2003-02-06, 23:15

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×