You Are Here:

Community: Developer Discussion Boards

#1 Old Question How to retrieve web browser's User Agent field in C++? - 2008-12-20, 11:37

Join Date: Dec 2007
Posts: 18
DeathBaba
Offline
Registered User
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?
Reply With Quote

#2 Old Re: How to retrieve web browser's User Agent field in C++? - 2008-12-22, 07:27

Join Date: Mar 2003
Posts: 6,209
petrib
Offline
Forum Nokia Champion
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.
Reply With Quote

#3 Old Re: How to retrieve web browser's User Agent field in C++? - 2008-12-22, 07:34

Join Date: Mar 2004
Posts: 1,925
Location: Czech Republic
stenlik's Avatar
stenlik
Offline
Forum Nokia Champion
Hi,

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

BR
STeN
Reply With Quote

#4 Old Re: How to retrieve web browser's User Agent field in C++? - 2008-12-22, 09:43

Join Date: Dec 2007
Posts: 18
DeathBaba
Offline
Registered User
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.
Reply With Quote

#5 Old Re: How to retrieve web browser's User Agent field in C++? - 2008-12-22, 10:45

Join Date: Mar 2003
Posts: 6,209
petrib
Offline
Forum Nokia Champion
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.
Reply With Quote

#6 Old Re: How to retrieve web browser's User Agent field in C++? - 2008-12-22, 11:56

Join Date: Dec 2007
Posts: 18
DeathBaba
Offline
Registered User
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.
Reply With Quote

#7 Old Re: How to retrieve web browser's User Agent field in C++? - 2008-12-23, 16:35

Join Date: Dec 2007
Posts: 18
DeathBaba
Offline
Registered User
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!
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Nokia User Agent Header rajendrap16 Browsing and Mark-ups 17 2008-02-24 16:43
modify the user agent on the fly ? wyzok Symbian Networking & Messaging 0 2007-03-16 16:56
How to identify a WAP browser / phone - User agent field frostyfone Browsing and Mark-ups 1 2001-11-08 15:26
User agent field in Nokia WAP phones nkn_aikon Browsing and Mark-ups 1 2001-11-08 15:24

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d180964X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZbrowsingQ qfnZtopicQUqfnTopicZwebE5ftechnologyQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ