Mathematica Asked on July 7, 2021
The documentation for HTTPRequest
notes that it is possible to indicate a user agent, and that
The default "UserAgent" is typically "Wolfram HTTPClient xxxx", where xxxx is a version number.
How can I find out what this version number is? Ideally this should be done locally and without outgoing network traffic.
I ask because I am writing code to probe an API and I would like to override the default UserAgent in a way that identifies the queries as coming from the package and giving a contact address, but without destroying existing information that could be useful in diagnosing any problems in the future.
HTTPRequest[""]["Headers"]
{"user-agent" -> "Wolfram HTTPClient 12.3"}
or
HTTPRequest["www.wolfram.com"] // ExportString[#, "HTTPRequest"] &
GET / HTTP/1.1 host: www.wolfram.com user-agent: Wolfram HTTPClient 12.3
Correct answer by Kuba on July 7, 2021
If you have the ability to CloudDeploy
functions, you can do it like so:
obj = CloudDeploy[APIFunction[{}, $UserAgentString &],
Permissions -> "Public"]
Import[First[obj]]
"Wolfram HTTPClient 12.2"
Make sure to clean up after yourself:
DeleteObject[obj]
What we are doing here is deploying an API endpoint that simply returns the User Agent string in the response body, then querying that API and outputting the body (by Import
ing the First
part of obj
, which is the URL of our API).
In any case, the expectation would be that the version in the user agent is going to be the version of the Wolfram Language you use.
Answered by Carl Lange on July 7, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP