×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    23

    Question How to retrieve web browser's User Agent field in C++?

    I've found one undocumented solution for S60 3rd edition here: http://discussion.forum.nokia.com/fo...d.php?t=143035 but it doesn't work on 3.2 devices.

    Does anyone know another methods?

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,557

    Re: How to retrieve web browser's User Agent field in C++?

    What do you need the user agent string for in an application running on the phone? What do you plan to do with the information? Maybe there are other ways to solve your problem, but without knowing what you are trying to accomplish it is hard to say.

  3. #3
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037

    Re: How to retrieve web browser's User Agent field in C++?

    Hi,

    why you need it runtime? Isn't http://whatsmyuseragent.com/ enough?

    BR
    STeN

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    23

    Re: How to retrieve web browser's User Agent field in C++?

    Browser's user agent field is needed on the server, which can be accessed as with real browser, as with application's custom HTTP request. Of course, it's possible to hard-code it for each device, but what in the case of firmware upgrade? That's why I'm looking for solution how to retrieve user agent at runtime.

  5. #5
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,557

    Re: How to retrieve web browser's User Agent field in C++?

    If you need it on the server, then the server will get it in the HTTP_USER-AGENT HTTP variable/header.

    Note that it is browser-specific, so if the user uses some other browser (e.g., Opera Mobile, Opera Mini, Skyfire, Netfront) besides the device's built-in browser, you will see a different HTTP_USER-AGENT at your server.

    And if the phone user is not using a browser at all, but an application that does its own HTTP handling, then the user-agent string/header can be anything the developer wishes it to be.

    Still, at least I'm not clear why you want to get the user-agent string by software running on the device? What will you do with the string on the device? If you want to identify the device model, then use the platform ID, instead.

  6. #6
    Registered User
    Join Date
    Dec 2007
    Posts
    23

    Re: How to retrieve web browser's User Agent field in C++?

    I want to send the exact user agent string from my app as a device's browser sends. Of course, it's possible to form it manually, but in my case I need exact the same string as a browser.

  7. #7
    Registered User
    Join Date
    Dec 2007
    Posts
    23

    Re: How to retrieve web browser's User Agent field in C++?

    Actually, I've found correct solution. In my case (newest 3.2 devices), browser's HTTP User Agent is located at another key index, in comparison to the link above. So, final code should be like this:

    TInt INDEX = 5; // it can be different on each platform/device, check everything from 0 to 14

    iRepository = CRepository::NewLC(TUid::Uid(0x101f8731));
    TBuf<255> tmp;
    iRepository->Get(INDEX, tmp);
    iUserAgent = HBufC8::NewL(tmp.Length());
    iUserAgent->Des().Copy(tmp);

    Thanks to everyone!

Similar Threads

  1. User agent field in Nokia WAP phones
    By nkn_aikon in forum Browsing and Mark-ups
    Replies: 4
    Last Post: 2010-04-16, 21:45
  2. Nokia User Agent Header
    By rajendrap16 in forum Browsing and Mark-ups
    Replies: 17
    Last Post: 2008-02-24, 15:43
  3. modify the user agent on the fly ?
    By wyzok in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2007-03-16, 15:56
  4. How to identify a WAP browser / phone - User agent field
    By frostyfone in forum Browsing and Mark-ups
    Replies: 1
    Last Post: 2001-11-08, 14:26

Posting Permissions

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