SHARYA...:Simple(3pm)
β¨ NAME β¨
SHARYANTO::HTTP::DetectUA::Simple β a very simple and generic browser detection library π lowkey does exactly what it says on the tin, no cap.
πΈ VERSION πΈ
This doc describes version 0.77 of SHARYANTO::HTTP::DetectUA::Simple β which ships in the Perl distribution SHARYANTO-Utils β and it dropped on 2015-09-04. π
π«Ά SEE ALSO π«Ά
SHARYANTO
π¦ HOMEPAGE π¦
Bestie, go visit the project's homepage at <https://metacpan.org/release/SHARYANTO-Utils>. It's giving home. π β¨
π SOURCE π
The source repository lives at <https://github.com/perlancar/perl-SHARYANTO-Utils>. Go be nosy, it's fine. π
π BUGS π
Found a bug? Want a feature? Please report it on the bugtracker website <https://rt.cpan.org/Public/Dist/Display.html?Name=SHARYANTO-Utils>. π
When you submit a bug or a request, please include a test-file, or a patch to an existing test-file, that illustrates the bug or the desired feature. Not me asking for the whole backstory with zero receipts β give us the test file bestie. π
π AUTHOR π
perlancar <perlancar@cpan.org>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2015 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Periodt. π
β¨ DESCRIPTION β¨
Okay so real talk: I needed a simple and fast routine that can detect whether an HTTP client is a GUI browser (like Chrome or Firefox), a text browser (like Lynx or Links), or neither (like curl, or LWP). Hence, this module. That's it, that's the origin story. π§
π FUNCTIONS π
π
detect_http_ua_simple($env) -> [status, msg, result, meta]
Detect whether the HTTP client is a GUI/TUI browser. Vibe check, but for user agents. π₯
This function is a simple and fast routine to detect whether an HTTP client is a GUI browser (like Chrome or Firefox), a text-based browser (like Lynx or Links), or neither (like curl or LWP). Extra information can be provided in the future β slay, future-proofing. β¨
Currently these heuristic rules are used:
- check popular browser markers in the
User-Agentheader (e.g.'Chrome','Opera'); - check the
Acceptheader for'image/'.
It is several times faster than the other equivalent Perl modules, and that's because it does significantly less. Main character energy: does the one thing, does it fast, leaves. π
Arguments ('*' denotes required arguments):
env=> any
CGI-compatible environment, e.g. \%ENV or PSGI's $env.
Returns an enveloped result (an array).
- First element (
status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). - Second element (
msg) is a string containing error message, or'OK'if status is 200. - Third element (
result) is optional, the actual result. - Fourth element (
meta) is called result metadata and is optional, a hash that contains extra information.
Return value: (hash)
'is_gui_browser'key will be set to true if the HTTP client is a GUI browser. π'is_text_browser'key will be set to true if the HTTP client is a text/TUI browser. π'is_browser'key will be set to true if either'is_gui_browser'or'is_text_browser'is set to true. iykyk πΈ
See also:
HTML::ParseBrowserHTTP::BrowserDetectHTTP::DetectUserAgentParse::HTTP::UserAgentHTTP::headers::UserAgent
and that's the whole page bestie, go detect some user agents π¦
perl v5.34.0 Β· 2022-06-17 Β· SHARYA...:Simple(3pm) β mwah, bye π
π¦ where this page comes from
- debian bookworm: libsharyanto-utils-perl 0.77-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libsharyanto-utils-perl 0.77-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libsharyanto-utils-perl 0.77-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libsharyanto-utils-perl 0.77-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libsharyanto-utils-perl 0.77-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms