×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    9

    Sending a POST message to PHP - HTTP/1.0 works, but HTTP/1.1 doesn't?

    I'm trying to send some XML content from the Sun Java Wireless Toolkit to
    Apache/2.2.3 web server running PHP version 5.1.6. Essential code for the Java ME application is:

    HttpConnection c = (HttpConnection) Connector.open(SERVER_URL, Connector.READ_WRITE);
    c.setRequestMethod(HttpConnection.POST);
    c.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.0");
    byte[] data = "[some xml data]".getBytes();
    c.setRequestProperty("Content-Length", String.valueOf(data.length));
    OutputStream os = conn.openOutputStream();
    os.write(data);
    os.flush();
    int responseCode = c.getResponseCode();
    //...

    And in the PHP script the data is read using $data = file_get_contents("php://input");

    This works, if in the Sun Java Wireless Toolkit the setting Preferences - Network Configuration - Http Version is set to HTTP/1.0, but if it is set to HTTP/1.1 the PHP script receives no data. Any ideas for what might be the problem?

  2. #2
    Regular Contributor
    Join Date
    Apr 2007
    Posts
    220

    Re: Sending a POST message to PHP - HTTP/1.0 works, but HTTP/1.1 doesn't?

    Hi,
    remove the os.flush() method and then try. the flush methods might be resulting in chunked data transaction.

    Regards

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    369

    Re: Sending a POST message to PHP - HTTP/1.0 works, but HTTP/1.1 doesn't?

    in the php do you use the Content-Length attribute to determine the amount of data received? if so DONT.
    just read it till u get EOF.

Similar Threads

  1. Sending long message
    By njoandy1 in forum Smart Messaging
    Replies: 2
    Last Post: 2005-02-06, 09:38
  2. Sending OTA service settings message
    By ab_hardware in forum Smart Messaging
    Replies: 4
    Last Post: 2004-12-15, 13:39
  3. Sending WAP Push Message / Service Settings Message
    By ivoice in forum Smart Messaging
    Replies: 1
    Last Post: 2003-07-22, 07:08
  4. Invalid request type: Post / HTTP/1.1
    By gulyasa in forum General Messaging
    Replies: 2
    Last Post: 2002-09-04, 12:21

Posting Permissions

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