PhpUserAgent icon indicating copy to clipboard operation
PhpUserAgent copied to clipboard

Support reading system details even the user agent is not fully written

Open samaphp opened this issue 8 years ago • 5 comments

Thank you for this amazing function <3

Current version does not support reading details in User-Agent if it is not full detailed. Example: User-Agent: AppName/1.0.23 (example.com/AppName; [email protected]).

It just read the AppName with version and does not read the system details.

This case usually used when contacting APIs where everyone should write self-described User-Agent.

Many Thanks

samaphp avatar Apr 27 '17 13:04 samaphp

I wrote extra code to support this kind of user-agents on this pull request #44

samaphp avatar Apr 27 '17 13:04 samaphp

The example you give doesn't appear to contain any system information? Please correct me if I'm misunderstanding.

If system info isn't provided I cannot provide details that are not in the user agent string itself. However if system information is provided ala

AppName/1.0.23 (example.com/AppName; [email protected]; Windows)

It does return AppName version 1.0.23 on Windows as one would expect.

donatj avatar Apr 27 '17 14:04 donatj

Thank you for this fast response. Depending on Wikipedia this part of User-Agent:

(iPad; U; CPU OS 3_2_1 like Mac OS X; en-us): Details of the system in which the browser is running. Refer to system and application details.

Also, it's most common when calling APIs that you should set a user-agent for all your requests like this New-Relic example.

and a lot of other API documentations.

So, now when I'm building an API I should take care of this kind of user-agents and read them correctly.

Thanks

samaphp avatar Apr 28 '17 01:04 samaphp

I made my comment before you submitted your PR. I can absolutely see a desire to get those parts of the UA string. I will need to take some time and experiment with how this applies to things across the board, but I really like the idea of your PR #44

donatj avatar Apr 28 '17 15:04 donatj

Yes sure, take your time. I already have my own fork with this update. If you have any notes I will be glad to resubmit my PR and fixing test assertion issue. Thanks for your time. And thanks again for this amazing function. :rose:

samaphp avatar Apr 28 '17 17:04 samaphp