user-agent

How to handle user-agent in nodejs environment?

若如初见. 提交于 2019-12-03 04:24:13
I start to using the package "ua-parser" but the creator is too busy to mantain or commit... the npm ua-parser is outdate, and need to download directly from github. Someone know about other good package like ua-parser that is updated and can be used with expressjs? Or have a way to handle just with expressjs? tpae Have you looked at: https://github.com/biggora/express-useragent Or, write your own middleware: app.use(function(req, res, next) { res.locals.ua = req.get('User-Agent'); next(); }); Reference: get user agent from inside jade There are two general situations, where you just need

Is it possible to use HttpBrowserCapabilities from a c# console application?

。_饼干妹妹 提交于 2019-12-03 01:35:18
I need to parse UserAgent strings from a console app and this seems like a simple way to do it, but I obviously don't have an HttpRequest object and can't seem to make a fake one with a User-Agent header (I get platform not supported exception). Is there any way to do this, or should I start exploring other alternatives to user agent parsing? The User-Agent header can be parsed by the HttpBrowserCapabilities class with the help of a BrowserCapabilitiesFactory , as follows: var userAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10) " + "Gecko/20100914 Firefox/3.6.10"; var

Detect iPhone browser in .htaccess/apache and redirect to iPhone site

笑着哭i 提交于 2019-12-03 00:43:56
Is it possible to detect iPhone browser agent in .htaccess and redirect the user to the correct iPhone page? Sure you can - #redirect mobile browsers RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$ RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301] RewriteCond %{HTTP_USER_AGENT} ^.*BlackBerry.*$ RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301] RewriteCond %{HTTP_USER_AGENT} ^.*Palm.*$ RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301] Taken from here A little Googling, even has a handy generator. http://detectmobilebrowsers.mobi/ To add to @Tommy's response, if you want to pass

Import from web - set user agent in Mathematica

社会主义新天地 提交于 2019-12-03 00:25:41
when I connect to my site with Mathermatica ( Import["mysite","Data"] ) and look at my Apache log I see: 99.XXX.XXX.XXX - - [22/May/2011:19:36:28 +0200] "GET / HTTP/1.1" 200 6268 "-" "Mathematica/8.0.1.0.0 PM/1.3.1" Could I set it to be something like this (when I connects with real browser): 99.XXX.XXX.XXX - - [22/May/2011:19:46:17 +0200] "GET /favicon.ico HTTP/1.1" 404 183 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24" Mathematica 9 has the new URLFetch function. It has the option UserAgent. As far as I know you can't change the

How exactly hash fragment based security works?

有些话、适合烂在心里 提交于 2019-12-02 23:07:34
I'm learning OAuth 2.0 and couldn't get the way of securing access token in implicit grant flow . There are some theses in specification and some upvoted SO answers looking contradicting to each other. Could somebody clear it up? Quotes from SO answers and specification that are confusing me: (From spec) Redirection URI used to deliver the access token to the client. The access token may be exposed to the resource owner or other applications with access to the resource owner's user-agent. (From spec) Access token credentials (as well as any confidential access token attributes) MUST be kept

How to detect device name in Safari on iOS 13 while it doesn't show the correct user agent?

拟墨画扇 提交于 2019-12-02 20:37:15
After Apple's iOS 13 reales, I realized window.navigator.userAgent in Safari on iPad iOS 13 is same as on MacOS. Something like this: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Safari/605.1.15 As you see, it's a wrong user-agent for iPad and even there is no way to detect if the current device is an iDevice. After an initial research, I found a work around for it: Go to Settings -> Safari -> Request Desktop Website -> All websites. You notice "All websites" is enabled by default . If you disable it and get window.navigator.userAgent the

Set useragent in WKWebview

独自空忆成欢 提交于 2019-12-02 20:11:07
How do I set a custom useragent string in a WKWebView? I'm trying to embed the version of my app so that my server-side can see what features are available. I found the following method: let userAgent = "MyApp/1.33.7" request.setValue(userAgent, forHTTPHeaderField: "User-Agent") NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {(response, data, error) in let content = NSString(data: data, encoding: NSUTF8StringEncoding) self.web!.loadHTMLString(content!, baseURL: url) } self.web!.loadRequest(request); But this means the useragent is only set for that single

Desktop/OS User Agents in Javascript

你。 提交于 2019-12-02 10:49:04
Below is my current script: <script type="text/javascript"> if (navigator.userAgent.indexOf('BlackBerry')!= -1){ document.write('<link rel="stylesheet" href="/m/css/mobile.css" type="text/css" />'); } else if (navigator.userAgent.indexOf('iPhone')!= -1) { document.write('<link rel="stylesheet" href="/m/css/smartmobile.css" type="text/css" />'); }else if (navigator.userAgent.indexOf('Android')!= -1) { document.write('<link rel="stylesheet" href="/m/css/smartmobile.css" type="text/css" />'); } else if (navigator.userAgent.indexOf('Windows XP')!= -1) { document.write('<link rel="stylesheet" href=

Detecting Chrome OS with Javascript

点点圈 提交于 2019-12-02 08:59:33
问题 I want to detect Chrome OS with Javascript, and I'm using navigator.userAgent for this. Now, I'm running Chrome OS, and my navigator userAgent is Mozilla/5.0 (X11; CrOS armv7l 6680.78.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.102 Safari/537.36 Now. I used Regular Expressions to check for the style of the userAgent, and wrote the code below. <script> if ( navigator.userAgent = /^Mozilla\/\d{1}^.\d{1}^(X11; CrOS i\d{3} \d{1}^.\d{2}\d{3} ^AppleWebKit\/\d{3}^.\d{2} ^(KHTML, like

Detecting Chrome OS with Javascript

*爱你&永不变心* 提交于 2019-12-02 04:08:23
I want to detect Chrome OS with Javascript, and I'm using navigator.userAgent for this. Now, I'm running Chrome OS, and my navigator userAgent is Mozilla/5.0 (X11; CrOS armv7l 6680.78.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.102 Safari/537.36 Now. I used Regular Expressions to check for the style of the userAgent, and wrote the code below. <script> if ( navigator.userAgent = /^Mozilla\/\d{1}^.\d{1}^(X11; CrOS i\d{3} \d{1}^.\d{2}\d{3} ^AppleWebKit\/\d{3}^.\d{2} ^(KHTML, like Gecko) Chrome\/ \d{2}^.\d{1}^.\d{3}^.\d{2} ^Safari\/\d{3}^\d{2}/ ){ console.log(navigator.userAgent); }