×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    29

    Headers and urlconnection

    What headerfields will a webserver receive if someone makes a urlconnection (GPRS) with for example a nokia telephone. Can a webwerver detect that the connection was from a mobilephone?

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395
    Hi!

    That's a good question... it's hard to know without looking, as it's not dependant upon the phone alone, but also the WAP gateway, which may change the headers in unexpected ways. I find that the content-type field gets changed when I make POST requests, for example. But for the most part, headers depend on you - on what you place in the header using the setRequestProperty of the HttpConnection object. You could add your own header item (such as a "user-agent" string) - this is described in the documentation of HttpConnection. If you want to know what you're running on, try using the system property "microedition.platform" - this gives me the string "Nokia6100/04.01".

    If you need to know exactly what you get, you need to write something on your server to catch the header and store it for you (or send it back as response content). But beware that it may be different for different phones and different networks.

    Any help?

    Cheers,
    Graham.

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    Graham is right. You're best bet if you want the server to recognize that it's talking to a phone is sending a user agent header. I find that this header is usually "left alone" by the WAP gateways.
    Code:
    HttpConnection c = null;
    // ....
    c.setRequestProperty("User-Agent", someStringYouCanUseToIdentifyTheMIDlet);

Posting Permissions

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